@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,180 +0,0 @@
1
- /* global document */
2
-
3
- /* eslint-disable complexity, max-statements */
4
-
5
- /*!
6
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
7
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
8
- *
9
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- *
14
- * See the License for the specific language governing permissions and limitations under the License.
15
- *
16
- */
17
- import { getOAuthUrls, loadFrame } from './util';
18
- import AuthSdkError from '../errors/AuthSdkError';
19
- import { prepareTokenParams } from './util/prepareTokenParams';
20
- import { buildAuthorizeParams } from './endpoints/authorize';
21
- import { addPostMessageListener } from './util';
22
- import { handleOAuthResponse } from './handleOAuthResponse';
23
- /*
24
- * Retrieve an idToken from an Okta or a third party idp
25
- *
26
- * Two main flows:
27
- *
28
- * 1) Exchange a sessionToken for a token
29
- *
30
- * Required:
31
- * clientId: passed via the OktaAuth constructor or into getToken
32
- * sessionToken: 'yourtoken'
33
- *
34
- * Optional:
35
- * redirectUri: defaults to window.location.href
36
- * scopes: defaults to ['openid', 'email']
37
- *
38
- * Forced:
39
- * prompt: 'none'
40
- * responseMode: 'okta_post_message'
41
- * display: undefined
42
- *
43
- * 2) Get a token from an idp
44
- *
45
- * Required:
46
- * clientId: passed via the OktaAuth constructor or into getToken
47
- *
48
- * Optional:
49
- * redirectUri: defaults to window.location.href
50
- * scopes: defaults to ['openid', 'email']
51
- * idp: defaults to Okta as an idp
52
- * prompt: no default. Pass 'none' to throw an error if user is not signed in
53
- *
54
- * Forced:
55
- * display: 'popup'
56
- *
57
- * Only common optional params shown. Any OAuth parameters not explicitly forced are available to override
58
- *
59
- * @param {Object} oauthOptions
60
- * @param {String} [oauthOptions.clientId] ID of this client
61
- * @param {String} [oauthOptions.redirectUri] URI that the iframe or popup will go to once authenticated
62
- * @param {String[]} [oauthOptions.scopes] OAuth 2.0 scopes to request (openid must be specified)
63
- * @param {String} [oauthOptions.idp] ID of an external IdP to use for user authentication
64
- * @param {String} [oauthOptions.sessionToken] Bootstrap Session Token returned by the Okta Authentication API
65
- * @param {String} [oauthOptions.prompt] Determines whether the Okta login will be displayed on failure.
66
- * Use 'none' to prevent this behavior
67
- *
68
- * @param {Object} options
69
- * @param {Integer} [options.timeout] Time in ms before the flow is automatically terminated. Defaults to 120000
70
- * @param {String} [options.popupTitle] Title dispayed in the popup.
71
- * Defaults to 'External Identity Provider User Authentication'
72
- */
73
-
74
- export function getToken(sdk, options) {
75
- if (arguments.length > 2) {
76
- return Promise.reject(new AuthSdkError('As of version 3.0, "getToken" takes only a single set of options'));
77
- }
78
-
79
- options = options || {}; // window object cannot be serialized, save for later use
80
- // TODO: move popup related params into a separate options object
81
-
82
- var popupWindow = options.popupWindow;
83
- options.popupWindow = undefined;
84
- return prepareTokenParams(sdk, options).then(function (tokenParams) {
85
- // Start overriding any options that don't make sense
86
- var sessionTokenOverrides = {
87
- prompt: 'none',
88
- responseMode: 'okta_post_message',
89
- display: null
90
- };
91
- var idpOverrides = {
92
- display: 'popup'
93
- };
94
-
95
- if (options.sessionToken) {
96
- Object.assign(tokenParams, sessionTokenOverrides);
97
- } else if (options.idp) {
98
- Object.assign(tokenParams, idpOverrides);
99
- } // Use the query params to build the authorize url
100
-
101
-
102
- var requestUrl, endpoint, urls; // Get authorizeUrl and issuer
103
-
104
- urls = getOAuthUrls(sdk, tokenParams);
105
- endpoint = options.codeVerifier ? urls.tokenUrl : urls.authorizeUrl;
106
- requestUrl = endpoint + buildAuthorizeParams(tokenParams); // Determine the flow type
107
-
108
- var flowType;
109
-
110
- if (tokenParams.sessionToken || tokenParams.display === null) {
111
- flowType = 'IFRAME';
112
- } else if (tokenParams.display === 'popup') {
113
- flowType = 'POPUP';
114
- } else {
115
- flowType = 'IMPLICIT';
116
- } // Execute the flow type
117
-
118
-
119
- switch (flowType) {
120
- case 'IFRAME':
121
- var iframePromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);
122
- var iframeEl = loadFrame(requestUrl);
123
- return iframePromise.then(function (res) {
124
- return handleOAuthResponse(sdk, tokenParams, res, urls);
125
- }).finally(function () {
126
- if (document.body.contains(iframeEl)) {
127
- iframeEl.parentElement.removeChild(iframeEl);
128
- }
129
- });
130
-
131
- case 'POPUP':
132
- var oauthPromise; // resolves with OAuth response
133
- // Add listener on postMessage before window creation, so
134
- // postMessage isn't triggered before we're listening
135
-
136
- if (tokenParams.responseMode === 'okta_post_message') {
137
- if (!sdk.features.isPopupPostMessageSupported()) {
138
- throw new AuthSdkError('This browser doesn\'t have full postMessage support');
139
- }
140
-
141
- oauthPromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);
142
- } // Redirect for authorization
143
- // popupWindown can be null when popup is blocked
144
-
145
-
146
- if (popupWindow) {
147
- popupWindow.location.assign(requestUrl);
148
- } // The popup may be closed without receiving an OAuth response. Setup a poller to monitor the window.
149
-
150
-
151
- var popupPromise = new Promise(function (resolve, reject) {
152
- var closePoller = setInterval(function () {
153
- if (!popupWindow || popupWindow.closed) {
154
- clearInterval(closePoller);
155
- reject(new AuthSdkError('Unable to parse OAuth flow response'));
156
- }
157
- }, 100); // Proxy the OAuth promise results
158
-
159
- oauthPromise.then(function (res) {
160
- clearInterval(closePoller);
161
- resolve(res);
162
- }).catch(function (err) {
163
- clearInterval(closePoller);
164
- reject(err);
165
- });
166
- });
167
- return popupPromise.then(function (res) {
168
- return handleOAuthResponse(sdk, tokenParams, res, urls);
169
- }).finally(function () {
170
- if (popupWindow && !popupWindow.closed) {
171
- popupWindow.close();
172
- }
173
- });
174
-
175
- default:
176
- throw new AuthSdkError('The full page redirect flow is not supported');
177
- }
178
- });
179
- }
180
- //# sourceMappingURL=getToken.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/getToken.ts"],"names":["getOAuthUrls","loadFrame","AuthSdkError","prepareTokenParams","buildAuthorizeParams","addPostMessageListener","handleOAuthResponse","getToken","sdk","options","arguments","length","Promise","reject","popupWindow","undefined","then","tokenParams","sessionTokenOverrides","prompt","responseMode","display","idpOverrides","sessionToken","Object","assign","idp","requestUrl","endpoint","urls","codeVerifier","tokenUrl","authorizeUrl","flowType","iframePromise","timeout","state","iframeEl","res","finally","document","body","contains","parentElement","removeChild","oauthPromise","features","isPopupPostMessageSupported","location","popupPromise","resolve","closePoller","setInterval","closed","clearInterval","catch","err","close"],"mappings":"AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,YADF,EAEEC,SAFF,QAGO,QAHP;AAKA,OAAOC,YAAP,MAAyB,wBAAzB;AAQA,SAASC,kBAAT,QAAmC,2BAAnC;AACA,SAASC,oBAAT,QAAqC,uBAArC;AACA,SAASC,sBAAT,QAAuC,QAAvC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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statements */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport {\n getOAuthUrls,\n loadFrame,\n} from './util';\n\nimport AuthSdkError from '../errors/AuthSdkError';\n\nimport {\n OktaAuth,\n TokenParams,\n PopupParams,\n} from '../types';\n\nimport { prepareTokenParams } from './util/prepareTokenParams';\nimport { buildAuthorizeParams } from './endpoints/authorize';\nimport { addPostMessageListener } from './util';\nimport { handleOAuthResponse } from './handleOAuthResponse';\n/*\n * Retrieve an idToken from an Okta or a third party idp\n *\n * Two main flows:\n *\n * 1) Exchange a sessionToken for a token\n *\n * Required:\n * clientId: passed via the OktaAuth constructor or into getToken\n * sessionToken: 'yourtoken'\n *\n * Optional:\n * redirectUri: defaults to window.location.href\n * scopes: defaults to ['openid', 'email']\n *\n * Forced:\n * prompt: 'none'\n * responseMode: 'okta_post_message'\n * display: undefined\n *\n * 2) Get a token from an idp\n *\n * Required:\n * clientId: passed via the OktaAuth constructor or into getToken\n *\n * Optional:\n * redirectUri: defaults to window.location.href\n * scopes: defaults to ['openid', 'email']\n * idp: defaults to Okta as an idp\n * prompt: no default. Pass 'none' to throw an error if user is not signed in\n *\n * Forced:\n * display: 'popup'\n *\n * Only common optional params shown. Any OAuth parameters not explicitly forced are available to override\n *\n * @param {Object} oauthOptions\n * @param {String} [oauthOptions.clientId] ID of this client\n * @param {String} [oauthOptions.redirectUri] URI that the iframe or popup will go to once authenticated\n * @param {String[]} [oauthOptions.scopes] OAuth 2.0 scopes to request (openid must be specified)\n * @param {String} [oauthOptions.idp] ID of an external IdP to use for user authentication\n * @param {String} [oauthOptions.sessionToken] Bootstrap Session Token returned by the Okta Authentication API\n * @param {String} [oauthOptions.prompt] Determines whether the Okta login will be displayed on failure.\n * Use 'none' to prevent this behavior\n *\n * @param {Object} options\n * @param {Integer} [options.timeout] Time in ms before the flow is automatically terminated. Defaults to 120000\n * @param {String} [options.popupTitle] Title dispayed in the popup.\n * Defaults to 'External Identity Provider User Authentication'\n */\nexport function getToken(sdk: OktaAuth, options: TokenParams & PopupParams) {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getToken\" takes only a single set of options'));\n }\n\n options = options || {};\n\n // window object cannot be serialized, save for later use\n // TODO: move popup related params into a separate options object\n const popupWindow = options.popupWindow;\n options.popupWindow = undefined;\n\n return prepareTokenParams(sdk, options)\n .then(function (tokenParams: TokenParams) {\n\n // Start overriding any options that don't make sense\n var sessionTokenOverrides = {\n prompt: 'none',\n responseMode: 'okta_post_message',\n display: null\n };\n\n var idpOverrides = {\n display: 'popup'\n };\n\n if (options.sessionToken) {\n Object.assign(tokenParams, sessionTokenOverrides);\n } else if (options.idp) {\n Object.assign(tokenParams, idpOverrides);\n }\n\n // Use the query params to build the authorize url\n var requestUrl,\n endpoint,\n urls;\n\n // Get authorizeUrl and issuer\n urls = getOAuthUrls(sdk, tokenParams);\n endpoint = options.codeVerifier ? urls.tokenUrl : urls.authorizeUrl;\n requestUrl = endpoint + buildAuthorizeParams(tokenParams);\n\n // Determine the flow type\n var flowType;\n if (tokenParams.sessionToken || tokenParams.display === null) {\n flowType = 'IFRAME';\n } else if (tokenParams.display === 'popup') {\n flowType = 'POPUP';\n } else {\n flowType = 'IMPLICIT';\n }\n\n // Execute the flow type\n switch (flowType) {\n case 'IFRAME':\n var iframePromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);\n var iframeEl = loadFrame(requestUrl);\n return iframePromise\n .then(function (res) {\n return handleOAuthResponse(sdk, tokenParams, res, urls);\n })\n .finally(function () {\n if (document.body.contains(iframeEl)) {\n iframeEl.parentElement.removeChild(iframeEl);\n }\n });\n\n case 'POPUP':\n var oauthPromise; // resolves with OAuth response\n\n // Add listener on postMessage before window creation, so\n // postMessage isn't triggered before we're listening\n if (tokenParams.responseMode === 'okta_post_message') {\n if (!sdk.features.isPopupPostMessageSupported()) {\n throw new AuthSdkError('This browser doesn\\'t have full postMessage support');\n }\n oauthPromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);\n }\n\n // Redirect for authorization\n // popupWindown can be null when popup is blocked\n if (popupWindow) { \n popupWindow.location.assign(requestUrl);\n }\n\n // The popup may be closed without receiving an OAuth response. Setup a poller to monitor the window.\n var popupPromise = new Promise(function (resolve, reject) {\n var closePoller = setInterval(function () {\n if (!popupWindow || popupWindow.closed) {\n clearInterval(closePoller);\n reject(new AuthSdkError('Unable to parse OAuth flow response'));\n }\n }, 100);\n\n // Proxy the OAuth promise results\n oauthPromise\n .then(function (res) {\n clearInterval(closePoller);\n resolve(res);\n })\n .catch(function (err) {\n clearInterval(closePoller);\n reject(err);\n });\n });\n\n return popupPromise\n .then(function (res) {\n return handleOAuthResponse(sdk, tokenParams, res, urls);\n })\n .finally(function () {\n if (popupWindow && !popupWindow.closed) {\n popupWindow.close();\n }\n });\n\n default:\n throw new AuthSdkError('The full page redirect flow is not supported');\n }\n });\n}"],"file":"getToken.js"}
@@ -1,82 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
-
3
- /* eslint-disable complexity */
4
-
5
- /*!
6
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
7
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
8
- *
9
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- *
14
- * See the License for the specific language governing permissions and limitations under the License.
15
- *
16
- */
17
- import { isFunction } from '../util';
18
- import { AuthSdkError, OAuthError } from '../errors';
19
- import { httpRequest } from '../http';
20
- import { isAccessToken, isIDToken } from '../types';
21
- export function getUserInfo(_x, _x2, _x3) {
22
- return _getUserInfo.apply(this, arguments);
23
- }
24
-
25
- function _getUserInfo() {
26
- _getUserInfo = _asyncToGenerator(function* (sdk, accessTokenObject, idTokenObject) {
27
- // If token objects were not passed, attempt to read from the TokenManager
28
- if (!accessTokenObject) {
29
- accessTokenObject = (yield sdk.tokenManager.getTokens()).accessToken;
30
- }
31
-
32
- if (!idTokenObject) {
33
- idTokenObject = (yield sdk.tokenManager.getTokens()).idToken;
34
- }
35
-
36
- if (!accessTokenObject || !isAccessToken(accessTokenObject)) {
37
- return Promise.reject(new AuthSdkError('getUserInfo requires an access token object'));
38
- }
39
-
40
- if (!idTokenObject || !isIDToken(idTokenObject)) {
41
- return Promise.reject(new AuthSdkError('getUserInfo requires an ID token object'));
42
- }
43
-
44
- return httpRequest(sdk, {
45
- url: accessTokenObject.userinfoUrl,
46
- method: 'GET',
47
- accessToken: accessTokenObject.accessToken
48
- }).then(userInfo => {
49
- // Only return the userinfo response if subjects match to mitigate token substitution attacks
50
- if (userInfo.sub === idTokenObject.claims.sub) {
51
- return userInfo;
52
- }
53
-
54
- return Promise.reject(new AuthSdkError('getUserInfo request was rejected due to token mismatch'));
55
- }).catch(function (err) {
56
- if (err.xhr && (err.xhr.status === 401 || err.xhr.status === 403)) {
57
- var authenticateHeader;
58
-
59
- if (err.xhr.headers && isFunction(err.xhr.headers.get) && err.xhr.headers.get('WWW-Authenticate')) {
60
- authenticateHeader = err.xhr.headers.get('WWW-Authenticate');
61
- } else if (isFunction(err.xhr.getResponseHeader)) {
62
- authenticateHeader = err.xhr.getResponseHeader('WWW-Authenticate');
63
- }
64
-
65
- if (authenticateHeader) {
66
- var errorMatches = authenticateHeader.match(/error="(.*?)"/) || [];
67
- var errorDescriptionMatches = authenticateHeader.match(/error_description="(.*?)"/) || [];
68
- var error = errorMatches[1];
69
- var errorDescription = errorDescriptionMatches[1];
70
-
71
- if (error && errorDescription) {
72
- err = new OAuthError(error, errorDescription);
73
- }
74
- }
75
- }
76
-
77
- throw err;
78
- });
79
- });
80
- return _getUserInfo.apply(this, arguments);
81
- }
82
- //# sourceMappingURL=getUserInfo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/getUserInfo.ts"],"names":["isFunction","AuthSdkError","OAuthError","httpRequest","isAccessToken","isIDToken","getUserInfo","sdk","accessTokenObject","idTokenObject","tokenManager","getTokens","accessToken","idToken","Promise","reject","url","userinfoUrl","method","then","userInfo","sub","claims","catch","err","xhr","status","authenticateHeader","headers","get","getResponseHeader","errorMatches","match","errorDescriptionMatches","error","errorDescription"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,SAA3B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,WAAzC;AACA,SAASC,WAAT,QAA4B,SAA5B;AACA,SAA2CC,aAA3C,EAA0DC,SAA1D,QAA2E,UAA3E;AAEA,gBAAsBC,WAAtB;AAAA;AAAA;;;mCAAO,WAA2BC,GAA3B,EAAgCC,iBAAhC,EAAgEC,aAAhE,EAA6G;AAClH;AACA,QAAI,CAACD,iBAAL,EAAwB;AACtBA,MAAAA,iBAAiB,GAAG,OAAOD,GAAG,CAACG,YAAJ,CAAiBC,SAAjB,EAAP,EAAqCC,WAAzD;AACD;;AACD,QAAI,CAACH,aAAL,EAAoB;AAClBA,MAAAA,aAAa,GAAG,OAAOF,GAAG,CAACG,YAAJ,CAAiBC,SAAjB,EAAP,EAAqCE,OAArD;AACD;;AAED,QAAI,CAACL,iBAAD,IAAsB,CAACJ,aAAa,CAACI,iBAAD,CAAxC,EAA6D;AAC3D,aAAOM,OAAO,CAACC,MAAR,CAAe,IAAId,YAAJ,CAAiB,6CAAjB,CAAf,CAAP;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,CAAQK,iBAAR,CAA0B,kBAA1B,CAArB;AACD;;AACD,YAAIH,kBAAJ,EAAwB;AACtB,cAAII,YAAY,GAAGJ,kBAAkB,CAACK,KAAnB,CAAyB,eAAzB,KAA6C,EAAhE;AACA,cAAIC,uBAAuB,GAAGN,kBAAkB,CAACK,KAAnB,CAAyB,2BAAzB,KAAyD,EAAvF;AACA,cAAIE,KAAK,GAAGH,YAAY,CAAC,CAAD,CAAxB;AACA,cAAII,gBAAgB,GAAGF,uBAAuB,CAAC,CAAD,CAA9C;;AACA,cAAIC,KAAK,IAAIC,gBAAb,EAA+B;AAC7BX,YAAAA,GAAG,GAAG,IAAItB,UAAJ,CAAegC,KAAf,EAAsBC,gBAAtB,CAAN;AACD;AACF;AACF;;AACD,YAAMX,GAAN;AACD,KA/BI,CAAP;AAgCD,G","sourcesContent":["/* eslint-disable complexity */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport { isFunction } from '../util';\nimport { AuthSdkError, OAuthError } from '../errors';\nimport { httpRequest } from '../http';\nimport { AccessToken, IDToken, UserClaims, isAccessToken, isIDToken } from '../types';\n\nexport async function getUserInfo(sdk, accessTokenObject: AccessToken, idTokenObject: IDToken): Promise<UserClaims> {\n // If token objects were not passed, attempt to read from the TokenManager\n if (!accessTokenObject) {\n accessTokenObject = (await sdk.tokenManager.getTokens()).accessToken as AccessToken;\n }\n if (!idTokenObject) {\n idTokenObject = (await sdk.tokenManager.getTokens()).idToken as IDToken;\n }\n\n if (!accessTokenObject || !isAccessToken(accessTokenObject)) {\n return Promise.reject(new AuthSdkError('getUserInfo requires an access token object'));\n }\n\n if (!idTokenObject || !isIDToken(idTokenObject)) {\n return Promise.reject(new AuthSdkError('getUserInfo requires an ID token object'));\n }\n\n return httpRequest(sdk, {\n url: accessTokenObject.userinfoUrl,\n method: 'GET',\n accessToken: accessTokenObject.accessToken\n })\n .then(userInfo => {\n // Only return the userinfo response if subjects match to mitigate token substitution attacks\n if (userInfo.sub === idTokenObject.claims.sub) {\n return userInfo;\n }\n return Promise.reject(new AuthSdkError('getUserInfo request was rejected due to token mismatch'));\n })\n .catch(function (err) {\n if (err.xhr && (err.xhr.status === 401 || err.xhr.status === 403)) {\n var authenticateHeader;\n if (err.xhr.headers && isFunction(err.xhr.headers.get) && err.xhr.headers.get('WWW-Authenticate')) {\n authenticateHeader = err.xhr.headers.get('WWW-Authenticate');\n } else if (isFunction(err.xhr.getResponseHeader)) {\n authenticateHeader = err.xhr.getResponseHeader('WWW-Authenticate');\n }\n if (authenticateHeader) {\n var errorMatches = authenticateHeader.match(/error=\"(.*?)\"/) || [];\n var errorDescriptionMatches = authenticateHeader.match(/error_description=\"(.*?)\"/) || [];\n var error = errorMatches[1];\n var errorDescription = errorDescriptionMatches[1];\n if (error && errorDescription) {\n err = new OAuthError(error, errorDescription);\n }\n }\n }\n throw err;\n });\n}\n"],"file":"getUserInfo.js"}
@@ -1,34 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- *
12
- */
13
- import { AuthSdkError } from '../errors';
14
- import { clone } from '../util';
15
- import { getToken } from './getToken';
16
- import { loadPopup } from './util';
17
- export function getWithPopup(sdk, options) {
18
- if (arguments.length > 2) {
19
- return Promise.reject(new AuthSdkError('As of version 3.0, "getWithPopup" takes only a single set of options'));
20
- } // some browsers (safari, firefox) block popup if it's initialed from an async process
21
- // here we create the popup window immediately after user interaction
22
- // then redirect to the /authorize endpoint when the requestUrl is available
23
-
24
-
25
- var popupWindow = loadPopup('/', options);
26
- options = clone(options) || {};
27
- Object.assign(options, {
28
- display: 'popup',
29
- responseMode: 'okta_post_message',
30
- popupWindow
31
- });
32
- return getToken(sdk, options);
33
- }
34
- //# sourceMappingURL=getWithPopup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/getWithPopup.ts"],"names":["AuthSdkError","clone","getToken","loadPopup","getWithPopup","sdk","options","arguments","length","Promise","reject","popupWindow","Object","assign","display","responseMode"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,WAA7B;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,QAAT,QAAyB,YAAzB;AACA,SAASC,SAAT,QAA0B,QAA1B;AAEA,OAAO,SAASC,YAAT,CAAsBC,GAAtB,EAAqCC,OAArC,EAAmF;AACxF,MAAIC,SAAS,CAACC,MAAV,GAAmB,CAAvB,EAA0B;AACxB,WAAOC,OAAO,CAACC,MAAR,CAAe,IAAIV,YAAJ,CAAiB,sEAAjB,CAAf,CAAP;AACD,GAHuF,CAKxF;AACA;AACA;;;AACA,MAAMW,WAAW,GAAGR,SAAS,CAAC,GAAD,EAAMG,OAAN,CAA7B;AACAA,EAAAA,OAAO,GAAGL,KAAK,CAACK,OAAD,CAAL,IAAkB,EAA5B;AACAM,EAAAA,MAAM,CAACC,MAAP,CAAcP,OAAd,EAAuB;AACrBQ,IAAAA,OAAO,EAAE,OADY;AAErBC,IAAAA,YAAY,EAAE,mBAFO;AAGrBJ,IAAAA;AAHqB,GAAvB;AAKA,SAAOT,QAAQ,CAACG,GAAD,EAAMC,OAAN,CAAf;AACD","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 */\nimport { AuthSdkError } from '../errors';\nimport { OktaAuth, TokenParams, TokenResponse } from '../types';\nimport { clone } from '../util';\nimport { getToken } from './getToken';\nimport { loadPopup } from './util';\n\nexport function getWithPopup(sdk: OktaAuth, options: TokenParams): Promise<TokenResponse> {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getWithPopup\" takes only a single set of options'));\n }\n\n // some browsers (safari, firefox) block popup if it's initialed from an async process\n // here we create the popup window immediately after user interaction\n // then redirect to the /authorize endpoint when the requestUrl is available\n const popupWindow = loadPopup('/', options);\n options = clone(options) || {};\n Object.assign(options, {\n display: 'popup',\n responseMode: 'okta_post_message',\n popupWindow\n });\n return getToken(sdk, options);\n}\n"],"file":"getWithPopup.js"}
@@ -1,65 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- *
12
- */
13
- import { AuthSdkError } from '../errors';
14
- import { clone } from '../util';
15
- import { getOAuthUrls, prepareTokenParams } from './util';
16
- import { buildAuthorizeParams } from './endpoints/authorize';
17
- export function getWithRedirect(sdk, options) {
18
- if (arguments.length > 2) {
19
- return Promise.reject(new AuthSdkError('As of version 3.0, "getWithRedirect" takes only a single set of options'));
20
- }
21
-
22
- options = clone(options) || {};
23
- return prepareTokenParams(sdk, options).then(function (tokenParams) {
24
- var urls = getOAuthUrls(sdk, options);
25
- var requestUrl = urls.authorizeUrl + buildAuthorizeParams(tokenParams);
26
- var issuer = sdk.options.issuer; // Gather the values we want to save in the transaction
27
-
28
- var {
29
- responseType,
30
- state,
31
- nonce,
32
- scopes,
33
- clientId,
34
- ignoreSignature,
35
- redirectUri,
36
- codeVerifier,
37
- codeChallenge,
38
- codeChallengeMethod
39
- } = tokenParams; // Also store the originalUri (if any) in the transaction meta.
40
- // This is needed to support continue flow in another tab.
41
-
42
- var originalUri = sdk.getOriginalUri();
43
- var oauthMeta = {
44
- issuer,
45
- responseType,
46
- state,
47
- nonce,
48
- scopes,
49
- clientId,
50
- urls,
51
- ignoreSignature,
52
- redirectUri,
53
- codeVerifier,
54
- codeChallenge,
55
- codeChallengeMethod,
56
- originalUri
57
- };
58
- sdk.transactionManager.save(oauthMeta, {
59
- oauth: true
60
- });
61
-
62
- sdk.token.getWithRedirect._setLocation(requestUrl);
63
- });
64
- }
65
- //# sourceMappingURL=getWithRedirect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/getWithRedirect.ts"],"names":["AuthSdkError","clone","getOAuthUrls","prepareTokenParams","buildAuthorizeParams","getWithRedirect","sdk","options","arguments","length","Promise","reject","then","tokenParams","urls","requestUrl","authorizeUrl","issuer","responseType","state","nonce","scopes","clientId","ignoreSignature","redirectUri","codeVerifier","codeChallenge","codeChallengeMethod","originalUri","getOriginalUri","oauthMeta","transactionManager","save","oauth","token","_setLocation"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,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;AAUjCC,MAAAA,YAViC;AAWjCC,MAAAA,aAXiC;AAYjCC,MAAAA,mBAZiC;AAajCC,MAAAA;AAbiC,KAAnC;AAgBAtB,IAAAA,GAAG,CAACyB,kBAAJ,CAAuBC,IAAvB,CAA4BF,SAA5B,EAAuC;AAAEG,MAAAA,KAAK,EAAE;AAAT,KAAvC;;AACA3B,IAAAA,GAAG,CAAC4B,KAAJ,CAAU7B,eAAV,CAA0B8B,YAA1B,CAAuCpB,UAAvC;AACD,GA1CI,CAAP;AA2CD","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 */\nimport { AuthSdkError } from '../errors';\nimport { OktaAuth, TokenParams, TransactionMeta } from '../types';\nimport { clone } from '../util';\nimport { getOAuthUrls, prepareTokenParams } from './util';\nimport { buildAuthorizeParams } from './endpoints/authorize';\n\nexport function getWithRedirect(sdk: OktaAuth, options: TokenParams): Promise<void> {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getWithRedirect\" takes only a single set of options'));\n }\n\n options = clone(options) || {};\n\n return prepareTokenParams(sdk, options)\n .then(function (tokenParams: TokenParams) {\n const urls = getOAuthUrls(sdk, options);\n const requestUrl = urls.authorizeUrl + buildAuthorizeParams(tokenParams);\n const issuer = sdk.options.issuer;\n\n // Gather the values we want to save in the transaction\n const {\n responseType,\n state,\n nonce,\n scopes,\n clientId,\n ignoreSignature,\n redirectUri,\n codeVerifier,\n codeChallenge,\n codeChallengeMethod,\n } = tokenParams;\n\n // Also store the originalUri (if any) in the transaction meta.\n // This is needed to support continue flow in another tab.\n const originalUri = sdk.getOriginalUri();\n\n const oauthMeta: TransactionMeta = {\n issuer,\n responseType,\n state,\n nonce,\n scopes,\n clientId,\n urls,\n ignoreSignature,\n redirectUri,\n codeVerifier,\n codeChallenge,\n codeChallengeMethod,\n originalUri,\n };\n\n sdk.transactionManager.save(oauthMeta, { oauth: true });\n sdk.token.getWithRedirect._setLocation(requestUrl);\n });\n}\n"],"file":"getWithRedirect.js"}
@@ -1,29 +0,0 @@
1
- /*!
2
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- *
12
- */
13
- import { AuthSdkError } from '../errors';
14
- import { clone } from '../util';
15
- import { getToken } from './getToken';
16
- export function getWithoutPrompt(sdk, options) {
17
- if (arguments.length > 2) {
18
- return Promise.reject(new AuthSdkError('As of version 3.0, "getWithoutPrompt" takes only a single set of options'));
19
- }
20
-
21
- options = clone(options) || {};
22
- Object.assign(options, {
23
- prompt: 'none',
24
- responseMode: 'okta_post_message',
25
- display: null
26
- });
27
- return getToken(sdk, options);
28
- }
29
- //# sourceMappingURL=getWithoutPrompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/getWithoutPrompt.ts"],"names":["AuthSdkError","clone","getToken","getWithoutPrompt","sdk","options","arguments","length","Promise","reject","Object","assign","prompt","responseMode","display"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,WAA7B;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,QAAT,QAAyB,YAAzB;AAEA,OAAO,SAASC,gBAAT,CAA0BC,GAA1B,EAAyCC,OAAzC,EAAuF;AAC5F,MAAIC,SAAS,CAACC,MAAV,GAAmB,CAAvB,EAA0B;AACxB,WAAOC,OAAO,CAACC,MAAR,CAAe,IAAIT,YAAJ,CAAiB,0EAAjB,CAAf,CAAP;AACD;;AAEDK,EAAAA,OAAO,GAAGJ,KAAK,CAACI,OAAD,CAAL,IAAkB,EAA5B;AACAK,EAAAA,MAAM,CAACC,MAAP,CAAcN,OAAd,EAAuB;AACrBO,IAAAA,MAAM,EAAE,MADa;AAErBC,IAAAA,YAAY,EAAE,mBAFO;AAGrBC,IAAAA,OAAO,EAAE;AAHY,GAAvB;AAKA,SAAOZ,QAAQ,CAACE,GAAD,EAAMC,OAAN,CAAf;AACD","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 */\nimport { AuthSdkError } from '../errors';\nimport { OktaAuth, TokenParams, TokenResponse } from '../types';\nimport { clone } from '../util';\nimport { getToken } from './getToken';\n\nexport function getWithoutPrompt(sdk: OktaAuth, options: TokenParams): Promise<TokenResponse> {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getWithoutPrompt\" takes only a single set of options'));\n }\n \n options = clone(options) || {};\n Object.assign(options, {\n prompt: 'none',\n responseMode: 'okta_post_message',\n display: null\n });\n return getToken(sdk, options);\n}\n\n"],"file":"getWithoutPrompt.js"}
@@ -1,148 +0,0 @@
1
- /* eslint-disable complexity, max-statements */
2
-
3
- /*!
4
- * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
5
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
6
- *
7
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
8
- * Unless required by applicable law or agreed to in writing, software
9
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- *
12
- * See the License for the specific language governing permissions and limitations under the License.
13
- *
14
- */
15
- import { clone } from '../util';
16
- import { getOAuthUrls } from './util/oauth';
17
- import { AuthSdkError, OAuthError } from '../errors';
18
- import { exchangeCodeForTokens } from './exchangeCodeForTokens';
19
- import { verifyToken } from './verifyToken';
20
- import { getDefaultTokenParams } from '.';
21
-
22
- function validateResponse(res, oauthParams) {
23
- if (res['error'] || res['error_description']) {
24
- throw new OAuthError(res['error'], res['error_description']);
25
- }
26
-
27
- if (res.state !== oauthParams.state) {
28
- throw new AuthSdkError('OAuth flow response state doesn\'t match request state');
29
- }
30
- } // eslint-disable-next-line max-len
31
-
32
-
33
- export function handleOAuthResponse(sdk, tokenParams, res, urls) {
34
- var pkce = sdk.options.pkce !== false; // The result contains an authorization_code and PKCE is enabled
35
- // `exchangeCodeForTokens` will call /token then call `handleOauthResponse` recursively with the result
36
-
37
- if (pkce && (res.code || res.interaction_code)) {
38
- return exchangeCodeForTokens(sdk, Object.assign({}, tokenParams, {
39
- authorizationCode: res.code,
40
- interactionCode: res.interaction_code
41
- }), urls);
42
- }
43
-
44
- tokenParams = tokenParams || getDefaultTokenParams(sdk);
45
- urls = urls || getOAuthUrls(sdk, tokenParams);
46
- var responseType = tokenParams.responseType;
47
-
48
- if (!Array.isArray(responseType)) {
49
- responseType = [responseType];
50
- }
51
-
52
- var scopes;
53
-
54
- if (res.scope) {
55
- scopes = res.scope.split(' ');
56
- } else {
57
- scopes = clone(tokenParams.scopes);
58
- }
59
-
60
- var clientId = tokenParams.clientId || sdk.options.clientId; // Handling the result from implicit flow or PKCE token exchange
61
-
62
- return Promise.resolve().then(function () {
63
- validateResponse(res, tokenParams);
64
- }).then(function () {
65
- var tokenDict = {};
66
- var expiresIn = res.expires_in;
67
- var tokenType = res.token_type;
68
- var accessToken = res.access_token;
69
- var idToken = res.id_token;
70
- var refreshToken = res.refresh_token;
71
- var now = Math.floor(Date.now() / 1000);
72
-
73
- if (accessToken) {
74
- var accessJwt = sdk.token.decode(accessToken);
75
- tokenDict.accessToken = {
76
- accessToken: accessToken,
77
- claims: accessJwt.payload,
78
- expiresAt: Number(expiresIn) + now,
79
- tokenType: tokenType,
80
- scopes: scopes,
81
- authorizeUrl: urls.authorizeUrl,
82
- userinfoUrl: urls.userinfoUrl
83
- };
84
- }
85
-
86
- if (refreshToken) {
87
- tokenDict.refreshToken = {
88
- refreshToken: refreshToken,
89
- // should not be used, this is the accessToken expire time
90
- // TODO: remove "expiresAt" in the next major version OKTA-407224
91
- expiresAt: Number(expiresIn) + now,
92
- scopes: scopes,
93
- tokenUrl: urls.tokenUrl,
94
- authorizeUrl: urls.authorizeUrl,
95
- issuer: urls.issuer
96
- };
97
- }
98
-
99
- if (idToken) {
100
- var idJwt = sdk.token.decode(idToken);
101
- var idTokenObj = {
102
- idToken: idToken,
103
- claims: idJwt.payload,
104
- expiresAt: idJwt.payload.exp - idJwt.payload.iat + now,
105
- // adjusting expiresAt to be in local time
106
- scopes: scopes,
107
- authorizeUrl: urls.authorizeUrl,
108
- issuer: urls.issuer,
109
- clientId: clientId
110
- };
111
- var validationParams = {
112
- clientId: clientId,
113
- issuer: urls.issuer,
114
- nonce: tokenParams.nonce,
115
- accessToken: accessToken
116
- };
117
-
118
- if (tokenParams.ignoreSignature !== undefined) {
119
- validationParams.ignoreSignature = tokenParams.ignoreSignature;
120
- }
121
-
122
- return verifyToken(sdk, idTokenObj, validationParams).then(function () {
123
- tokenDict.idToken = idTokenObj;
124
- return tokenDict;
125
- });
126
- }
127
-
128
- return tokenDict;
129
- }).then(function (tokenDict) {
130
- // Validate received tokens against requested response types
131
- if (responseType.indexOf('token') !== -1 && !tokenDict.accessToken) {
132
- // eslint-disable-next-line max-len
133
- throw new AuthSdkError('Unable to parse OAuth flow response: response type "token" was requested but "access_token" was not returned.');
134
- }
135
-
136
- if (responseType.indexOf('id_token') !== -1 && !tokenDict.idToken) {
137
- // eslint-disable-next-line max-len
138
- throw new AuthSdkError('Unable to parse OAuth flow response: response type "id_token" was requested but "id_token" was not returned.');
139
- }
140
-
141
- return {
142
- tokens: tokenDict,
143
- state: res.state,
144
- code: res.code
145
- };
146
- });
147
- }
148
- //# sourceMappingURL=handleOAuthResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../lib/oidc/handleOAuthResponse.ts"],"names":["clone","getOAuthUrls","AuthSdkError","OAuthError","exchangeCodeForTokens","verifyToken","getDefaultTokenParams","validateResponse","res","oauthParams","state","handleOAuthResponse","sdk","tokenParams","urls","pkce","options","code","interaction_code","Object","assign","authorizationCode","interactionCode","responseType","Array","isArray","scopes","scope","split","clientId","Promise","resolve","then","tokenDict","expiresIn","expires_in","tokenType","token_type","accessToken","access_token","idToken","id_token","refreshToken","refresh_token","now","Math","floor","Date","accessJwt","token","decode","claims","payload","expiresAt","Number","authorizeUrl","userinfoUrl","tokenUrl","issuer","idJwt","idTokenObj","exp","iat","validationParams","nonce","ignoreSignature","undefined","indexOf","tokens"],"mappings":"AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,SAAtB;AACA,SACEC,YADF,QAEO,cAFP;AAGA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,WAAzC;AAWA,SAASC,qBAAT,QAAsC,yBAAtC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,qBAAT,QAAsC,GAAtC;;AAEA,SAASC,gBAAT,CAA0BC,GAA1B,EAA8CC,WAA9C,EAAwE;AACtE,MAAID,GAAG,CAAC,OAAD,CAA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gD,UAAN,EAAkBG,gBAAlB,CAAX,CACJ/B,IADI,CACC,YAAY;AAChBC,QAAAA,SAAS,CAACO,OAAV,GAAoBoB,UAApB;AACA,eAAO3B,SAAP;AACD,OAJI,CAAP;AAKD;;AAED,WAAOA,SAAP;AACD,GAtEI,EAuEJD,IAvEI,CAuEC,UAAUC,SAAV,EAAoC;AACxC;AACA,QAAIV,YAAY,CAAC4C,OAAb,CAAqB,OAArB,MAAkC,CAAC,CAAnC,IAAwC,CAAClC,SAAS,CAACK,WAAvD,EAAoE;AAClE;AACA,YAAM,IAAIpC,YAAJ,CAAiB,+GAAjB,CAAN;AACD;;AACD,QAAIqB,YAAY,CAAC4C,OAAb,CAAqB,UAArB,MAAqC,CAAC,CAAtC,IAA2C,CAAClC,SAAS,CAACO,OAA1D,EAAmE;AACjE;AACA,YAAM,IAAItC,YAAJ,CAAiB,8GAAjB,CAAN;AACD;;AAED,WAAO;AACLkE,MAAAA,MAAM,EAAEnC,SADH;AAELvB,MAAAA,KAAK,EAAEF,GAAG,CAACE,KAFN;AAGLO,MAAAA,IAAI,EAAET,GAAG,CAACS;AAHL,KAAP;AAKD,GAvFI,CAAP;AAwFD","sourcesContent":["\n/* eslint-disable complexity, max-statements */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport { clone } from '../util';\nimport {\n getOAuthUrls,\n} from './util/oauth';\nimport { AuthSdkError, OAuthError } from '../errors';\nimport {\n OktaAuth,\n TokenVerifyParams,\n IDToken,\n OAuthResponse,\n TokenParams,\n TokenResponse,\n CustomUrls,\n Tokens,\n} from '../types';\nimport { exchangeCodeForTokens } from './exchangeCodeForTokens';\nimport { verifyToken } from './verifyToken';\nimport { getDefaultTokenParams } from '.';\n\nfunction validateResponse(res: OAuthResponse, oauthParams: TokenParams) {\n if (res['error'] || res['error_description']) {\n throw new OAuthError(res['error'], res['error_description']);\n }\n\n if (res.state !== oauthParams.state) {\n throw new AuthSdkError('OAuth flow response state doesn\\'t match request state');\n }\n}\n\n// eslint-disable-next-line max-len\nexport function handleOAuthResponse(sdk: OktaAuth, tokenParams: TokenParams, res: OAuthResponse, urls: CustomUrls): Promise<TokenResponse> {\n var pkce = sdk.options.pkce !== false;\n\n // The result contains an authorization_code and PKCE is enabled \n // `exchangeCodeForTokens` will call /token then call `handleOauthResponse` recursively with the result\n if (pkce && (res.code || res.interaction_code)) {\n return exchangeCodeForTokens(sdk, Object.assign({}, tokenParams, {\n authorizationCode: res.code,\n interactionCode: res.interaction_code\n }), urls);\n }\n\n tokenParams = tokenParams || getDefaultTokenParams(sdk);\n urls = urls || getOAuthUrls(sdk, tokenParams);\n\n var responseType = tokenParams.responseType;\n if (!Array.isArray(responseType)) {\n responseType = [responseType];\n }\n\n var scopes;\n if (res.scope) {\n scopes = res.scope.split(' ');\n } else {\n scopes = clone(tokenParams.scopes);\n }\n var clientId = tokenParams.clientId || sdk.options.clientId;\n\n // Handling the result from implicit flow or PKCE token exchange\n return Promise.resolve()\n .then(function () {\n validateResponse(res, tokenParams);\n }).then(function () {\n var tokenDict = {} as Tokens;\n var expiresIn = res.expires_in;\n var tokenType = res.token_type;\n var accessToken = res.access_token;\n var idToken = res.id_token;\n var refreshToken = res.refresh_token;\n var now = Math.floor(Date.now()/1000);\n\n if (accessToken) {\n var accessJwt = sdk.token.decode(accessToken);\n tokenDict.accessToken = {\n accessToken: accessToken,\n claims: accessJwt.payload,\n expiresAt: Number(expiresIn) + now,\n tokenType: tokenType,\n scopes: scopes,\n authorizeUrl: urls.authorizeUrl,\n userinfoUrl: urls.userinfoUrl\n };\n }\n\n if (refreshToken) {\n tokenDict.refreshToken = {\n refreshToken: refreshToken,\n // should not be used, this is the accessToken expire time\n // TODO: remove \"expiresAt\" in the next major version OKTA-407224\n expiresAt: Number(expiresIn) + now, \n scopes: scopes,\n tokenUrl: urls.tokenUrl,\n authorizeUrl: urls.authorizeUrl,\n issuer: urls.issuer,\n };\n }\n\n if (idToken) {\n var idJwt = sdk.token.decode(idToken);\n\n var idTokenObj: IDToken = {\n idToken: idToken,\n claims: idJwt.payload,\n expiresAt: idJwt.payload.exp - idJwt.payload.iat + now, // adjusting expiresAt to be in local time\n scopes: scopes,\n authorizeUrl: urls.authorizeUrl,\n issuer: urls.issuer,\n clientId: clientId\n };\n\n var validationParams: TokenVerifyParams = {\n clientId: clientId,\n issuer: urls.issuer,\n nonce: tokenParams.nonce,\n accessToken: accessToken\n };\n\n if (tokenParams.ignoreSignature !== undefined) {\n validationParams.ignoreSignature = tokenParams.ignoreSignature;\n }\n\n return verifyToken(sdk, idTokenObj, validationParams)\n .then(function () {\n tokenDict.idToken = idTokenObj;\n return tokenDict;\n });\n }\n\n return tokenDict;\n })\n .then(function (tokenDict): TokenResponse {\n // Validate received tokens against requested response types \n if (responseType.indexOf('token') !== -1 && !tokenDict.accessToken) {\n // eslint-disable-next-line max-len\n throw new AuthSdkError('Unable to parse OAuth flow response: response type \"token\" was requested but \"access_token\" was not returned.');\n }\n if (responseType.indexOf('id_token') !== -1 && !tokenDict.idToken) {\n // eslint-disable-next-line max-len\n throw new AuthSdkError('Unable to parse OAuth flow response: response type \"id_token\" was requested but \"id_token\" was not returned.');\n }\n\n return {\n tokens: tokenDict,\n state: res.state,\n code: res.code\n };\n });\n}"],"file":"handleOAuthResponse.js"}