@okta/okta-auth-js 7.5.1 → 7.7.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 (415) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +168 -4
  3. package/cjs/base/types.js.map +1 -1
  4. package/cjs/core/ServiceManager/browser.js +10 -2
  5. package/cjs/core/ServiceManager/browser.js.map +1 -1
  6. package/cjs/core/types/Service.js.map +1 -1
  7. package/cjs/errors/OAuthError.js +9 -1
  8. package/cjs/errors/OAuthError.js.map +1 -1
  9. package/cjs/errors/WWWAuthError.js +98 -0
  10. package/cjs/errors/WWWAuthError.js.map +1 -0
  11. package/cjs/errors/index.js +14 -1
  12. package/cjs/errors/index.js.map +1 -1
  13. package/cjs/features.js +10 -1
  14. package/cjs/features.js.map +1 -1
  15. package/cjs/http/OktaUserAgent.js +2 -2
  16. package/cjs/http/request.js +24 -25
  17. package/cjs/http/request.js.map +1 -1
  18. package/cjs/idx/IdxTransactionManager.js +5 -0
  19. package/cjs/idx/IdxTransactionManager.js.map +1 -1
  20. package/cjs/idx/authenticator/Authenticator.js.map +1 -1
  21. package/cjs/idx/authenticator/OktaPassword.js +16 -4
  22. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  23. package/cjs/idx/run.js +6 -3
  24. package/cjs/idx/run.js.map +1 -1
  25. package/cjs/idx/types/idx-js.js.map +1 -1
  26. package/cjs/idx/types/options.js.map +1 -1
  27. package/cjs/oidc/TokenManager.js +17 -1
  28. package/cjs/oidc/TokenManager.js.map +1 -1
  29. package/cjs/oidc/dpop.js +231 -0
  30. package/cjs/oidc/dpop.js.map +1 -0
  31. package/cjs/oidc/endpoints/token.js +77 -27
  32. package/cjs/oidc/endpoints/token.js.map +1 -1
  33. package/cjs/oidc/exchangeCodeForTokens.js +51 -28
  34. package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
  35. package/cjs/oidc/getUserInfo.js +32 -17
  36. package/cjs/oidc/getUserInfo.js.map +1 -1
  37. package/cjs/oidc/handleOAuthResponse.js +12 -0
  38. package/cjs/oidc/handleOAuthResponse.js.map +1 -1
  39. package/cjs/oidc/mixin/index.js +79 -2
  40. package/cjs/oidc/mixin/index.js.map +1 -1
  41. package/cjs/oidc/options/OAuthOptionsConstructor.js +3 -1
  42. package/cjs/oidc/options/OAuthOptionsConstructor.js.map +1 -1
  43. package/cjs/oidc/renewToken.js +4 -2
  44. package/cjs/oidc/renewToken.js.map +1 -1
  45. package/cjs/oidc/renewTokens.js +3 -1
  46. package/cjs/oidc/renewTokens.js.map +1 -1
  47. package/cjs/oidc/renewTokensWithRefresh.js +13 -2
  48. package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
  49. package/cjs/oidc/types/Token.js.map +1 -1
  50. package/cjs/oidc/types/api.js.map +1 -1
  51. package/cjs/oidc/types/options.js.map +1 -1
  52. package/cjs/oidc/util/defaultTokenParams.js +4 -2
  53. package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
  54. package/cjs/oidc/util/prepareTokenParams.js +3 -0
  55. package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
  56. package/cjs/services/RenewOnTabActivationService.js +64 -0
  57. package/cjs/services/RenewOnTabActivationService.js.map +1 -0
  58. package/cjs/services/index.js +11 -0
  59. package/cjs/services/index.js.map +1 -1
  60. package/dist/okta-auth-js.authn.min.analyzer.html +2 -2
  61. package/dist/okta-auth-js.authn.min.js +1 -1
  62. package/dist/okta-auth-js.authn.min.js.map +1 -1
  63. package/dist/okta-auth-js.core.min.analyzer.html +2 -2
  64. package/dist/okta-auth-js.core.min.js +1 -1
  65. package/dist/okta-auth-js.core.min.js.map +1 -1
  66. package/dist/okta-auth-js.idx.min.analyzer.html +2 -2
  67. package/dist/okta-auth-js.idx.min.js +1 -1
  68. package/dist/okta-auth-js.idx.min.js.map +1 -1
  69. package/dist/okta-auth-js.min.analyzer.html +2 -2
  70. package/dist/okta-auth-js.min.js +1 -1
  71. package/dist/okta-auth-js.min.js.map +1 -1
  72. package/dist/okta-auth-js.myaccount.min.analyzer.html +2 -2
  73. package/dist/okta-auth-js.myaccount.min.js +1 -1
  74. package/dist/okta-auth-js.myaccount.min.js.map +1 -1
  75. package/esm/browser/authn/api.js +1 -0
  76. package/esm/browser/authn/api.js.map +1 -1
  77. package/esm/browser/authn/util/link2fn.js +1 -0
  78. package/esm/browser/authn/util/link2fn.js.map +1 -1
  79. package/esm/browser/authn/util/poll.js +1 -0
  80. package/esm/browser/authn/util/poll.js.map +1 -1
  81. package/esm/browser/browser/fingerprint.js +1 -0
  82. package/esm/browser/browser/fingerprint.js.map +1 -1
  83. package/esm/browser/core/AuthStateManager.js +1 -0
  84. package/esm/browser/core/AuthStateManager.js.map +1 -1
  85. package/esm/browser/core/ServiceManager/browser.js +9 -2
  86. package/esm/browser/core/ServiceManager/browser.js.map +1 -1
  87. package/esm/browser/core/options.js +1 -0
  88. package/esm/browser/core/options.js.map +1 -1
  89. package/esm/browser/crypto/base64.js +1 -0
  90. package/esm/browser/crypto/base64.js.map +1 -1
  91. package/esm/browser/errors/OAuthError.js +5 -1
  92. package/esm/browser/errors/OAuthError.js.map +1 -1
  93. package/esm/browser/errors/WWWAuthError.js +61 -0
  94. package/esm/browser/errors/WWWAuthError.js.map +1 -0
  95. package/esm/browser/errors/index.js +6 -1
  96. package/esm/browser/errors/index.js.map +1 -1
  97. package/esm/browser/exports/exports/authn.js +2 -1
  98. package/esm/browser/exports/exports/authn.js.map +1 -1
  99. package/esm/browser/exports/exports/core.js +2 -1
  100. package/esm/browser/exports/exports/core.js.map +1 -1
  101. package/esm/browser/exports/exports/default.js +2 -1
  102. package/esm/browser/exports/exports/default.js.map +1 -1
  103. package/esm/browser/exports/exports/idx.js +2 -1
  104. package/esm/browser/exports/exports/idx.js.map +1 -1
  105. package/esm/browser/exports/exports/myaccount.js +2 -1
  106. package/esm/browser/exports/exports/myaccount.js.map +1 -1
  107. package/esm/browser/features.js +12 -2
  108. package/esm/browser/features.js.map +1 -1
  109. package/esm/browser/http/OktaUserAgent.js +2 -2
  110. package/esm/browser/http/options.js +1 -0
  111. package/esm/browser/http/options.js.map +1 -1
  112. package/esm/browser/http/request.js +14 -25
  113. package/esm/browser/http/request.js.map +1 -1
  114. package/esm/browser/idx/IdxTransactionManager.js +4 -1
  115. package/esm/browser/idx/IdxTransactionManager.js.map +1 -1
  116. package/esm/browser/idx/authenticator/Authenticator.js.map +1 -1
  117. package/esm/browser/idx/authenticator/OktaPassword.js +17 -4
  118. package/esm/browser/idx/authenticator/OktaPassword.js.map +1 -1
  119. package/esm/browser/idx/cancel.js +1 -0
  120. package/esm/browser/idx/cancel.js.map +1 -1
  121. package/esm/browser/idx/factory/api.js +1 -0
  122. package/esm/browser/idx/factory/api.js.map +1 -1
  123. package/esm/browser/idx/flow/AccountUnlockFlow.js +1 -0
  124. package/esm/browser/idx/flow/AccountUnlockFlow.js.map +1 -1
  125. package/esm/browser/idx/flow/AuthenticationFlow.js +1 -0
  126. package/esm/browser/idx/flow/AuthenticationFlow.js.map +1 -1
  127. package/esm/browser/idx/flow/PasswordRecoveryFlow.js +1 -0
  128. package/esm/browser/idx/flow/PasswordRecoveryFlow.js.map +1 -1
  129. package/esm/browser/idx/flow/RegistrationFlow.js +1 -0
  130. package/esm/browser/idx/flow/RegistrationFlow.js.map +1 -1
  131. package/esm/browser/idx/handleInteractionCodeRedirect.js +1 -0
  132. package/esm/browser/idx/handleInteractionCodeRedirect.js.map +1 -1
  133. package/esm/browser/idx/idxState/v1/generateIdxAction.js +1 -0
  134. package/esm/browser/idx/idxState/v1/generateIdxAction.js.map +1 -1
  135. package/esm/browser/idx/idxState/v1/idxResponseParser.js +1 -0
  136. package/esm/browser/idx/idxState/v1/idxResponseParser.js.map +1 -1
  137. package/esm/browser/idx/interact.js +1 -0
  138. package/esm/browser/idx/interact.js.map +1 -1
  139. package/esm/browser/idx/proceed.js +1 -0
  140. package/esm/browser/idx/proceed.js.map +1 -1
  141. package/esm/browser/idx/recoverPassword.js +1 -0
  142. package/esm/browser/idx/recoverPassword.js.map +1 -1
  143. package/esm/browser/idx/register.js +1 -0
  144. package/esm/browser/idx/register.js.map +1 -1
  145. package/esm/browser/idx/remediate.js +1 -0
  146. package/esm/browser/idx/remediate.js.map +1 -1
  147. package/esm/browser/idx/remediators/GenericRemediator/util.js +2 -0
  148. package/esm/browser/idx/remediators/GenericRemediator/util.js.map +1 -1
  149. package/esm/browser/idx/run.js +3 -3
  150. package/esm/browser/idx/run.js.map +1 -1
  151. package/esm/browser/idx/transactionMeta.js +1 -0
  152. package/esm/browser/idx/transactionMeta.js.map +1 -1
  153. package/esm/browser/idx/types/idx-js.js.map +1 -1
  154. package/esm/browser/idx/unlockAccount.js +1 -0
  155. package/esm/browser/idx/unlockAccount.js.map +1 -1
  156. package/esm/browser/myaccount/request.js +1 -0
  157. package/esm/browser/myaccount/request.js.map +1 -1
  158. package/esm/browser/oidc/TokenManager.js +13 -1
  159. package/esm/browser/oidc/TokenManager.js.map +1 -1
  160. package/esm/browser/oidc/decodeToken.js +1 -0
  161. package/esm/browser/oidc/decodeToken.js.map +1 -1
  162. package/esm/browser/oidc/dpop.js +160 -0
  163. package/esm/browser/oidc/dpop.js.map +1 -0
  164. package/esm/browser/oidc/endpoints/authorize.js +1 -0
  165. package/esm/browser/oidc/endpoints/authorize.js.map +1 -1
  166. package/esm/browser/oidc/endpoints/token.js +57 -24
  167. package/esm/browser/oidc/endpoints/token.js.map +1 -1
  168. package/esm/browser/oidc/endpoints/well-known.js +1 -0
  169. package/esm/browser/oidc/endpoints/well-known.js.map +1 -1
  170. package/esm/browser/oidc/enrollAuthenticator.js +1 -0
  171. package/esm/browser/oidc/enrollAuthenticator.js.map +1 -1
  172. package/esm/browser/oidc/exchangeCodeForTokens.js +40 -25
  173. package/esm/browser/oidc/exchangeCodeForTokens.js.map +1 -1
  174. package/esm/browser/oidc/factory/api.js +1 -0
  175. package/esm/browser/oidc/factory/api.js.map +1 -1
  176. package/esm/browser/oidc/factory/baseApi.js +1 -0
  177. package/esm/browser/oidc/factory/baseApi.js.map +1 -1
  178. package/esm/browser/oidc/getToken.js +1 -0
  179. package/esm/browser/oidc/getToken.js.map +1 -1
  180. package/esm/browser/oidc/getUserInfo.js +22 -18
  181. package/esm/browser/oidc/getUserInfo.js.map +1 -1
  182. package/esm/browser/oidc/getWithPopup.js +1 -0
  183. package/esm/browser/oidc/getWithPopup.js.map +1 -1
  184. package/esm/browser/oidc/getWithRedirect.js +1 -0
  185. package/esm/browser/oidc/getWithRedirect.js.map +1 -1
  186. package/esm/browser/oidc/getWithoutPrompt.js +1 -0
  187. package/esm/browser/oidc/getWithoutPrompt.js.map +1 -1
  188. package/esm/browser/oidc/handleOAuthResponse.js +10 -0
  189. package/esm/browser/oidc/handleOAuthResponse.js.map +1 -1
  190. package/esm/browser/oidc/introspect.js +1 -0
  191. package/esm/browser/oidc/introspect.js.map +1 -1
  192. package/esm/browser/oidc/mixin/index.js +78 -2
  193. package/esm/browser/oidc/mixin/index.js.map +1 -1
  194. package/esm/browser/oidc/mixin/minimal.js +1 -0
  195. package/esm/browser/oidc/mixin/minimal.js.map +1 -1
  196. package/esm/browser/oidc/options/OAuthOptionsConstructor.js +2 -1
  197. package/esm/browser/oidc/options/OAuthOptionsConstructor.js.map +1 -1
  198. package/esm/browser/oidc/parseFromUrl.js +1 -0
  199. package/esm/browser/oidc/parseFromUrl.js.map +1 -1
  200. package/esm/browser/oidc/renewToken.js +4 -2
  201. package/esm/browser/oidc/renewToken.js.map +1 -1
  202. package/esm/browser/oidc/renewTokens.js +4 -1
  203. package/esm/browser/oidc/renewTokens.js.map +1 -1
  204. package/esm/browser/oidc/renewTokensWithRefresh.js +12 -5
  205. package/esm/browser/oidc/renewTokensWithRefresh.js.map +1 -1
  206. package/esm/browser/oidc/revokeToken.js +1 -0
  207. package/esm/browser/oidc/revokeToken.js.map +1 -1
  208. package/esm/browser/oidc/storage.js +1 -0
  209. package/esm/browser/oidc/storage.js.map +1 -1
  210. package/esm/browser/oidc/types/Token.js.map +1 -1
  211. package/esm/browser/oidc/util/browser.js +1 -0
  212. package/esm/browser/oidc/util/browser.js.map +1 -1
  213. package/esm/browser/oidc/util/defaultTokenParams.js +3 -2
  214. package/esm/browser/oidc/util/defaultTokenParams.js.map +1 -1
  215. package/esm/browser/oidc/util/prepareEnrollAuthenticatorParams.js +1 -0
  216. package/esm/browser/oidc/util/prepareEnrollAuthenticatorParams.js.map +1 -1
  217. package/esm/browser/oidc/util/prepareTokenParams.js +4 -0
  218. package/esm/browser/oidc/util/prepareTokenParams.js.map +1 -1
  219. package/esm/browser/oidc/util/validateToken.js +1 -0
  220. package/esm/browser/oidc/util/validateToken.js.map +1 -1
  221. package/esm/browser/oidc/verifyToken.js +1 -0
  222. package/esm/browser/oidc/verifyToken.js.map +1 -1
  223. package/esm/browser/package.json +1 -1
  224. package/esm/browser/services/AutoRenewService.js +1 -0
  225. package/esm/browser/services/AutoRenewService.js.map +1 -1
  226. package/esm/browser/services/RenewOnTabActivationService.js +67 -0
  227. package/esm/browser/services/RenewOnTabActivationService.js.map +1 -0
  228. package/esm/browser/services/SyncStorageService.js +1 -0
  229. package/esm/browser/services/SyncStorageService.js.map +1 -1
  230. package/esm/browser/session/api.js +1 -0
  231. package/esm/browser/session/api.js.map +1 -1
  232. package/esm/node/authn/api.js +1 -0
  233. package/esm/node/authn/api.js.map +1 -1
  234. package/esm/node/authn/util/link2fn.js +1 -0
  235. package/esm/node/authn/util/link2fn.js.map +1 -1
  236. package/esm/node/authn/util/poll.js +1 -0
  237. package/esm/node/authn/util/poll.js.map +1 -1
  238. package/esm/node/browser/fingerprint.js +1 -0
  239. package/esm/node/browser/fingerprint.js.map +1 -1
  240. package/esm/node/core/AuthStateManager.js +1 -0
  241. package/esm/node/core/AuthStateManager.js.map +1 -1
  242. package/esm/node/core/options.js +1 -0
  243. package/esm/node/core/options.js.map +1 -1
  244. package/esm/node/crypto/base64.js +1 -0
  245. package/esm/node/crypto/base64.js.map +1 -1
  246. package/esm/node/errors/OAuthError.js +5 -1
  247. package/esm/node/errors/OAuthError.js.map +1 -1
  248. package/esm/node/errors/WWWAuthError.js +61 -0
  249. package/esm/node/errors/WWWAuthError.js.map +1 -0
  250. package/esm/node/errors/index.js +6 -1
  251. package/esm/node/errors/index.js.map +1 -1
  252. package/esm/node/exports/exports/authn.js +2 -1
  253. package/esm/node/exports/exports/authn.js.map +1 -1
  254. package/esm/node/exports/exports/core.js +2 -1
  255. package/esm/node/exports/exports/core.js.map +1 -1
  256. package/esm/node/exports/exports/default.js +2 -1
  257. package/esm/node/exports/exports/default.js.map +1 -1
  258. package/esm/node/exports/exports/idx.js +2 -1
  259. package/esm/node/exports/exports/idx.js.map +1 -1
  260. package/esm/node/exports/exports/myaccount.js +2 -1
  261. package/esm/node/exports/exports/myaccount.js.map +1 -1
  262. package/esm/node/features.js +12 -2
  263. package/esm/node/features.js.map +1 -1
  264. package/esm/node/http/OktaUserAgent.js +2 -2
  265. package/esm/node/http/options.js +1 -0
  266. package/esm/node/http/options.js.map +1 -1
  267. package/esm/node/http/request.js +14 -25
  268. package/esm/node/http/request.js.map +1 -1
  269. package/esm/node/idx/IdxTransactionManager.js +4 -1
  270. package/esm/node/idx/IdxTransactionManager.js.map +1 -1
  271. package/esm/node/idx/authenticator/Authenticator.js.map +1 -1
  272. package/esm/node/idx/authenticator/OktaPassword.js +17 -4
  273. package/esm/node/idx/authenticator/OktaPassword.js.map +1 -1
  274. package/esm/node/idx/cancel.js +1 -0
  275. package/esm/node/idx/cancel.js.map +1 -1
  276. package/esm/node/idx/factory/api.js +1 -0
  277. package/esm/node/idx/factory/api.js.map +1 -1
  278. package/esm/node/idx/flow/AccountUnlockFlow.js +1 -0
  279. package/esm/node/idx/flow/AccountUnlockFlow.js.map +1 -1
  280. package/esm/node/idx/flow/AuthenticationFlow.js +1 -0
  281. package/esm/node/idx/flow/AuthenticationFlow.js.map +1 -1
  282. package/esm/node/idx/flow/PasswordRecoveryFlow.js +1 -0
  283. package/esm/node/idx/flow/PasswordRecoveryFlow.js.map +1 -1
  284. package/esm/node/idx/flow/RegistrationFlow.js +1 -0
  285. package/esm/node/idx/flow/RegistrationFlow.js.map +1 -1
  286. package/esm/node/idx/handleInteractionCodeRedirect.js +1 -0
  287. package/esm/node/idx/handleInteractionCodeRedirect.js.map +1 -1
  288. package/esm/node/idx/idxState/v1/generateIdxAction.js +1 -0
  289. package/esm/node/idx/idxState/v1/generateIdxAction.js.map +1 -1
  290. package/esm/node/idx/idxState/v1/idxResponseParser.js +1 -0
  291. package/esm/node/idx/idxState/v1/idxResponseParser.js.map +1 -1
  292. package/esm/node/idx/interact.js +1 -0
  293. package/esm/node/idx/interact.js.map +1 -1
  294. package/esm/node/idx/proceed.js +1 -0
  295. package/esm/node/idx/proceed.js.map +1 -1
  296. package/esm/node/idx/recoverPassword.js +1 -0
  297. package/esm/node/idx/recoverPassword.js.map +1 -1
  298. package/esm/node/idx/register.js +1 -0
  299. package/esm/node/idx/register.js.map +1 -1
  300. package/esm/node/idx/remediate.js +1 -0
  301. package/esm/node/idx/remediate.js.map +1 -1
  302. package/esm/node/idx/remediators/GenericRemediator/util.js +2 -0
  303. package/esm/node/idx/remediators/GenericRemediator/util.js.map +1 -1
  304. package/esm/node/idx/run.js +3 -3
  305. package/esm/node/idx/run.js.map +1 -1
  306. package/esm/node/idx/transactionMeta.js +1 -0
  307. package/esm/node/idx/transactionMeta.js.map +1 -1
  308. package/esm/node/idx/types/idx-js.js.map +1 -1
  309. package/esm/node/idx/unlockAccount.js +1 -0
  310. package/esm/node/idx/unlockAccount.js.map +1 -1
  311. package/esm/node/myaccount/request.js +1 -0
  312. package/esm/node/myaccount/request.js.map +1 -1
  313. package/esm/node/oidc/TokenManager.js +13 -1
  314. package/esm/node/oidc/TokenManager.js.map +1 -1
  315. package/esm/node/oidc/decodeToken.js +1 -0
  316. package/esm/node/oidc/decodeToken.js.map +1 -1
  317. package/esm/node/oidc/dpop.js +160 -0
  318. package/esm/node/oidc/dpop.js.map +1 -0
  319. package/esm/node/oidc/endpoints/authorize.js +1 -0
  320. package/esm/node/oidc/endpoints/authorize.js.map +1 -1
  321. package/esm/node/oidc/endpoints/token.js +57 -24
  322. package/esm/node/oidc/endpoints/token.js.map +1 -1
  323. package/esm/node/oidc/endpoints/well-known.js +1 -0
  324. package/esm/node/oidc/endpoints/well-known.js.map +1 -1
  325. package/esm/node/oidc/enrollAuthenticator.js +1 -0
  326. package/esm/node/oidc/enrollAuthenticator.js.map +1 -1
  327. package/esm/node/oidc/exchangeCodeForTokens.js +40 -25
  328. package/esm/node/oidc/exchangeCodeForTokens.js.map +1 -1
  329. package/esm/node/oidc/factory/api.js +1 -0
  330. package/esm/node/oidc/factory/api.js.map +1 -1
  331. package/esm/node/oidc/factory/baseApi.js +1 -0
  332. package/esm/node/oidc/factory/baseApi.js.map +1 -1
  333. package/esm/node/oidc/getToken.js +1 -0
  334. package/esm/node/oidc/getToken.js.map +1 -1
  335. package/esm/node/oidc/getUserInfo.js +22 -18
  336. package/esm/node/oidc/getUserInfo.js.map +1 -1
  337. package/esm/node/oidc/getWithPopup.js +1 -0
  338. package/esm/node/oidc/getWithPopup.js.map +1 -1
  339. package/esm/node/oidc/getWithRedirect.js +1 -0
  340. package/esm/node/oidc/getWithRedirect.js.map +1 -1
  341. package/esm/node/oidc/getWithoutPrompt.js +1 -0
  342. package/esm/node/oidc/getWithoutPrompt.js.map +1 -1
  343. package/esm/node/oidc/handleOAuthResponse.js +10 -0
  344. package/esm/node/oidc/handleOAuthResponse.js.map +1 -1
  345. package/esm/node/oidc/introspect.js +1 -0
  346. package/esm/node/oidc/introspect.js.map +1 -1
  347. package/esm/node/oidc/mixin/index.js +78 -2
  348. package/esm/node/oidc/mixin/index.js.map +1 -1
  349. package/esm/node/oidc/mixin/minimal.js +1 -0
  350. package/esm/node/oidc/mixin/minimal.js.map +1 -1
  351. package/esm/node/oidc/options/OAuthOptionsConstructor.js +2 -1
  352. package/esm/node/oidc/options/OAuthOptionsConstructor.js.map +1 -1
  353. package/esm/node/oidc/parseFromUrl.js +1 -0
  354. package/esm/node/oidc/parseFromUrl.js.map +1 -1
  355. package/esm/node/oidc/renewToken.js +4 -2
  356. package/esm/node/oidc/renewToken.js.map +1 -1
  357. package/esm/node/oidc/renewTokens.js +4 -1
  358. package/esm/node/oidc/renewTokens.js.map +1 -1
  359. package/esm/node/oidc/renewTokensWithRefresh.js +12 -5
  360. package/esm/node/oidc/renewTokensWithRefresh.js.map +1 -1
  361. package/esm/node/oidc/revokeToken.js +1 -0
  362. package/esm/node/oidc/revokeToken.js.map +1 -1
  363. package/esm/node/oidc/storage.js +1 -0
  364. package/esm/node/oidc/storage.js.map +1 -1
  365. package/esm/node/oidc/types/Token.js.map +1 -1
  366. package/esm/node/oidc/util/browser.js +1 -0
  367. package/esm/node/oidc/util/browser.js.map +1 -1
  368. package/esm/node/oidc/util/defaultTokenParams.js +3 -2
  369. package/esm/node/oidc/util/defaultTokenParams.js.map +1 -1
  370. package/esm/node/oidc/util/prepareEnrollAuthenticatorParams.js +1 -0
  371. package/esm/node/oidc/util/prepareEnrollAuthenticatorParams.js.map +1 -1
  372. package/esm/node/oidc/util/prepareTokenParams.js +4 -0
  373. package/esm/node/oidc/util/prepareTokenParams.js.map +1 -1
  374. package/esm/node/oidc/util/validateToken.js +1 -0
  375. package/esm/node/oidc/util/validateToken.js.map +1 -1
  376. package/esm/node/oidc/verifyToken.js +1 -0
  377. package/esm/node/oidc/verifyToken.js.map +1 -1
  378. package/esm/node/package.json +1 -1
  379. package/esm/node/server/serverStorage.js +1 -0
  380. package/esm/node/server/serverStorage.js.map +1 -1
  381. package/esm/node/session/api.js +1 -0
  382. package/esm/node/session/api.js.map +1 -1
  383. package/esm/node/storage/options/StorageOptionsConstructor.js +1 -0
  384. package/esm/node/storage/options/StorageOptionsConstructor.js.map +1 -1
  385. package/package.json +5 -6
  386. package/types/lib/base/types.d.ts +1 -0
  387. package/types/lib/core/options.d.ts +1 -0
  388. package/types/lib/core/types/Service.d.ts +7 -1
  389. package/types/lib/errors/OAuthError.d.ts +3 -1
  390. package/types/lib/errors/WWWAuthError.d.ts +29 -0
  391. package/types/lib/errors/index.d.ts +3 -1
  392. package/types/lib/features.d.ts +1 -0
  393. package/types/lib/idx/authenticator/Authenticator.d.ts +1 -1
  394. package/types/lib/idx/authenticator/OktaPassword.d.ts +2 -1
  395. package/types/lib/idx/options.d.ts +1 -0
  396. package/types/lib/idx/types/idx-js.d.ts +1 -0
  397. package/types/lib/idx/types/options.d.ts +1 -0
  398. package/types/lib/oidc/dpop.d.ts +35 -0
  399. package/types/lib/oidc/endpoints/token.d.ts +5 -2
  400. package/types/lib/oidc/options/OAuthOptionsConstructor.d.ts +1 -0
  401. package/types/lib/oidc/types/Token.d.ts +2 -0
  402. package/types/lib/oidc/types/api.d.ts +14 -0
  403. package/types/lib/oidc/types/options.d.ts +3 -0
  404. package/types/lib/services/RenewOnTabActivationService.d.ts +16 -0
  405. package/types/lib/services/index.d.ts +1 -0
  406. package/umd/authn.js +1 -1
  407. package/umd/authn.js.map +1 -1
  408. package/umd/core.js +1 -1
  409. package/umd/core.js.map +1 -1
  410. package/umd/default.js +1 -1
  411. package/umd/default.js.map +1 -1
  412. package/umd/idx.js +1 -1
  413. package/umd/idx.js.map +1 -1
  414. package/umd/myaccount.js +1 -1
  415. package/umd/myaccount.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TokenManager.js","names":["DEFAULT_OPTIONS","autoRenew","autoRemove","syncStorage","clearPendingRemoveTokens","storage","undefined","expireEarlySeconds","storageKey","TOKEN_STORAGE_NAME","defaultState","expireTimeouts","renewPromise","TokenManager","on","event","handler","context","emitter","off","constructor","sdk","options","AuthSdkError","Object","assign","removeNils","isLocalhost","storageOptions","secure","storageProvider","storageType","storageManager","getTokenStorage","useSeparateCookies","clock","SdkClock","create","state","start","setExpireEventTimeoutAll","started","stop","clearExpireEventTimeoutAll","isStarted","getOptions","clone","getExpireTime","token","expireTime","expiresAt","hasExpired","now","emitExpired","key","emit","EVENT_EXPIRED","emitRenewed","freshToken","oldToken","EVENT_RENEWED","emitAdded","EVENT_ADDED","emitRemoved","EVENT_REMOVED","emitError","error","EVENT_ERROR","clearExpireEventTimeout","clearTimeout","prototype","hasOwnProperty","call","setExpireEventTimeout","isRefreshToken","expireEventWait","Math","max","expireEventTimeout","setTimeout","tokenStorage","getStorage","resetExpireEventTimeoutAll","add","validateToken","setStorage","emitSetStorageEvent","getSync","get","getTokensSync","tokens","keys","forEach","isAccessToken","accessToken","isIDToken","idToken","refreshToken","getTokens","getStorageKeyByType","type","filter","getTokenType","isIE11OrLess","EVENT_SET_STORAGE","setTokens","accessTokenCb","idTokenCb","refreshTokenCb","handleTokenCallback","handleAdded","handleRenewed","handleRemoved","types","existingTokens","reduce","newToken","existingToken","remove","removedToken","renewToken","renew","err","Promise","reject","renewTokens","then","tokenType","catch","tokenKey","finally","clear","clearStorage","removedTokens","pendingRemove","updateRefreshToken","REFRESH_TOKEN_STORAGE_KEY","removeRefreshToken","addPendingRemoveFlags"],"sources":["../../../lib/oidc/TokenManager.ts"],"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 { removeNils, clone } from '../util';\nimport { AuthSdkError } from '../errors';\nimport { validateToken } from '../oidc/util';\nimport { isLocalhost, isIE11OrLess } from '../features';\nimport SdkClock from '../clock';\nimport {\n Token, \n Tokens, \n TokenType, \n TokenManagerOptions, \n isIDToken, \n isAccessToken,\n isRefreshToken,\n TokenManagerErrorEventHandler,\n TokenManagerSetStorageEventHandler,\n TokenManagerRenewEventHandler,\n TokenManagerEventHandler,\n TokenManagerInterface,\n RefreshToken,\n AccessTokenCallback,\n IDTokenCallback,\n RefreshTokenCallback,\n EVENT_RENEWED,\n EVENT_ADDED,\n EVENT_ERROR,\n EVENT_EXPIRED,\n EVENT_REMOVED,\n EVENT_SET_STORAGE,\n TokenManagerAnyEventHandler,\n TokenManagerAnyEvent,\n OktaAuthOAuthInterface\n} from './types';\nimport { REFRESH_TOKEN_STORAGE_KEY, TOKEN_STORAGE_NAME } from '../constants';\nimport { EventEmitter } from '../base/types';\nimport { StorageOptions, StorageProvider, StorageType } from '../storage/types';\n\nconst DEFAULT_OPTIONS = {\n // TODO: remove in next major version - OKTA-473815\n autoRenew: true,\n autoRemove: true,\n syncStorage: true,\n // --- //\n clearPendingRemoveTokens: true,\n storage: undefined, // will use value from storageManager config\n expireEarlySeconds: 30,\n storageKey: TOKEN_STORAGE_NAME\n};\n\ninterface TokenManagerState {\n expireTimeouts: Record<string, unknown>;\n renewPromise: Promise<Token | undefined> | null;\n started?: boolean;\n}\nfunction defaultState(): TokenManagerState {\n return {\n expireTimeouts: {},\n renewPromise: null\n };\n}\nexport class TokenManager implements TokenManagerInterface {\n private sdk: OktaAuthOAuthInterface;\n private clock: SdkClock;\n private emitter: EventEmitter;\n private storage: StorageProvider;\n private state: TokenManagerState;\n private options: TokenManagerOptions;\n\n on(event: typeof EVENT_RENEWED, handler: TokenManagerRenewEventHandler, context?: object): void;\n on(event: typeof EVENT_ERROR, handler: TokenManagerErrorEventHandler, context?: object): void;\n on(event: typeof EVENT_SET_STORAGE, handler: TokenManagerSetStorageEventHandler, context?: object): void;\n on(event: typeof EVENT_EXPIRED | typeof EVENT_ADDED | typeof EVENT_REMOVED, \n handler: TokenManagerEventHandler, context?: object): void;\n on(event: TokenManagerAnyEvent, handler: TokenManagerAnyEventHandler, context?: object): void {\n if (context) {\n this.emitter.on(event, handler, context);\n } else {\n this.emitter.on(event, handler);\n }\n }\n\n off(event: typeof EVENT_RENEWED, handler?: TokenManagerRenewEventHandler): void;\n off(event: typeof EVENT_ERROR, handler?: TokenManagerErrorEventHandler): void;\n off(event: typeof EVENT_SET_STORAGE, handler?: TokenManagerSetStorageEventHandler): void;\n off(event: typeof EVENT_EXPIRED | typeof EVENT_ADDED | typeof EVENT_REMOVED, \n handler?: TokenManagerEventHandler): void;\n off(event: TokenManagerAnyEvent, handler?: TokenManagerAnyEventHandler): void {\n if (handler) {\n this.emitter.off(event, handler);\n } else {\n this.emitter.off(event);\n }\n }\n\n // eslint-disable-next-line complexity\n constructor(sdk: OktaAuthOAuthInterface, options: TokenManagerOptions = {}) {\n this.sdk = sdk;\n this.emitter = (sdk as any).emitter;\n if (!this.emitter) {\n throw new AuthSdkError('Emitter should be initialized before TokenManager');\n }\n \n options = Object.assign({}, DEFAULT_OPTIONS, removeNils(options));\n if (!isLocalhost()) {\n options.expireEarlySeconds = DEFAULT_OPTIONS.expireEarlySeconds;\n }\n\n this.options = options;\n\n const storageOptions: StorageOptions = removeNils({\n storageKey: options.storageKey,\n secure: options.secure,\n });\n if (typeof options.storage === 'object') {\n // A custom storage provider must implement getItem(key) and setItem(key, val)\n storageOptions.storageProvider = options.storage;\n } else if (options.storage) {\n storageOptions.storageType = options.storage as StorageType;\n }\n\n this.storage = sdk.storageManager.getTokenStorage({...storageOptions, useSeparateCookies: true});\n this.clock = SdkClock.create(/* sdk, options */);\n this.state = defaultState();\n }\n\n start() {\n if (this.options.clearPendingRemoveTokens) {\n this.clearPendingRemoveTokens();\n }\n this.setExpireEventTimeoutAll();\n this.state.started = true;\n }\n \n stop() {\n this.clearExpireEventTimeoutAll();\n this.state.started = false;\n }\n\n isStarted() {\n return !!this.state.started;\n }\n\n getOptions(): TokenManagerOptions {\n return clone(this.options);\n }\n \n getExpireTime(token) {\n const expireEarlySeconds = this.options.expireEarlySeconds || 0;\n var expireTime = token.expiresAt - expireEarlySeconds;\n return expireTime;\n }\n \n hasExpired(token) {\n var expireTime = this.getExpireTime(token);\n return expireTime <= this.clock.now();\n }\n \n emitExpired(key, token) {\n this.emitter.emit(EVENT_EXPIRED, key, token);\n }\n \n emitRenewed(key, freshToken, oldToken) {\n this.emitter.emit(EVENT_RENEWED, key, freshToken, oldToken);\n }\n \n emitAdded(key, token) {\n this.emitter.emit(EVENT_ADDED, key, token);\n }\n \n emitRemoved(key, token?) {\n this.emitter.emit(EVENT_REMOVED, key, token);\n }\n \n emitError(error) {\n this.emitter.emit(EVENT_ERROR, error);\n }\n \n clearExpireEventTimeout(key) {\n clearTimeout(this.state.expireTimeouts[key] as any);\n delete this.state.expireTimeouts[key];\n \n // Remove the renew promise (if it exists)\n this.state.renewPromise = null;\n }\n \n clearExpireEventTimeoutAll() {\n var expireTimeouts = this.state.expireTimeouts;\n for (var key in expireTimeouts) {\n if (!Object.prototype.hasOwnProperty.call(expireTimeouts, key)) {\n continue;\n }\n this.clearExpireEventTimeout(key);\n }\n }\n \n setExpireEventTimeout(key, token) {\n if (isRefreshToken(token)) {\n return;\n }\n\n var expireTime = this.getExpireTime(token);\n var expireEventWait = Math.max(expireTime - this.clock.now(), 0) * 1000;\n \n // Clear any existing timeout\n this.clearExpireEventTimeout(key);\n \n var expireEventTimeout = setTimeout(() => {\n this.emitExpired(key, token);\n }, expireEventWait);\n \n // Add a new timeout\n this.state.expireTimeouts[key] = expireEventTimeout;\n }\n \n setExpireEventTimeoutAll() {\n var tokenStorage = this.storage.getStorage();\n for(var key in tokenStorage) {\n if (!Object.prototype.hasOwnProperty.call(tokenStorage, key)) {\n continue;\n }\n var token = tokenStorage[key];\n this.setExpireEventTimeout(key, token);\n }\n }\n \n // reset timeouts to setup autoRenew for tokens from other document context (tabs)\n resetExpireEventTimeoutAll() {\n this.clearExpireEventTimeoutAll();\n this.setExpireEventTimeoutAll();\n }\n \n add(key, token: Token) {\n var tokenStorage = this.storage.getStorage();\n validateToken(token);\n tokenStorage[key] = token;\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n this.emitAdded(key, token);\n this.setExpireEventTimeout(key, token);\n }\n \n getSync(key): Token | undefined {\n var tokenStorage = this.storage.getStorage();\n return tokenStorage[key];\n }\n \n async get(key): Promise<Token | undefined> {\n return this.getSync(key);\n }\n \n getTokensSync(): Tokens {\n const tokens = {} as Tokens;\n const tokenStorage = this.storage.getStorage();\n Object.keys(tokenStorage).forEach(key => {\n const token = tokenStorage[key];\n if (isAccessToken(token)) {\n tokens.accessToken = token;\n } else if (isIDToken(token)) {\n tokens.idToken = token;\n } else if (isRefreshToken(token)) { \n tokens.refreshToken = token;\n }\n });\n return tokens;\n }\n \n async getTokens(): Promise<Tokens> {\n return this.getTokensSync();\n }\n\n getStorageKeyByType(type: TokenType): string {\n const tokenStorage = this.storage.getStorage();\n const key = Object.keys(tokenStorage).filter(key => {\n const token = tokenStorage[key];\n return (isAccessToken(token) && type === 'accessToken') \n || (isIDToken(token) && type === 'idToken')\n || (isRefreshToken(token) && type === 'refreshToken');\n })[0];\n return key;\n }\n\n private getTokenType(token: Token): TokenType {\n if (isAccessToken(token)) {\n return 'accessToken';\n }\n if (isIDToken(token)) {\n return 'idToken';\n }\n if(isRefreshToken(token)) {\n return 'refreshToken';\n }\n throw new AuthSdkError('Unknown token type');\n }\n\n // for synchronization of LocalStorage cross tabs for IE11\n private emitSetStorageEvent() {\n if (isIE11OrLess()) {\n const storage = this.storage.getStorage();\n this.emitter.emit(EVENT_SET_STORAGE, storage);\n }\n }\n\n // used in `SyncStorageService` for synchronization of LocalStorage cross tabs for IE11\n public getStorage() {\n return this.storage;\n }\n\n setTokens(\n tokens: Tokens,\n // TODO: callbacks can be removed in the next major version OKTA-407224\n accessTokenCb?: AccessTokenCallback, \n idTokenCb?: IDTokenCallback,\n refreshTokenCb?: RefreshTokenCallback\n ): void {\n const handleTokenCallback = (key, token) => {\n const type = this.getTokenType(token);\n if (type === 'accessToken') {\n accessTokenCb && accessTokenCb(key, token);\n } else if (type === 'idToken') {\n idTokenCb && idTokenCb(key, token);\n } else if (type === 'refreshToken') {\n refreshTokenCb && refreshTokenCb(key, token);\n }\n };\n const handleAdded = (key, token) => {\n this.emitAdded(key, token);\n this.setExpireEventTimeout(key, token);\n handleTokenCallback(key, token);\n };\n const handleRenewed = (key, token, oldToken) => {\n this.emitRenewed(key, token, oldToken);\n this.clearExpireEventTimeout(key);\n this.setExpireEventTimeout(key, token);\n handleTokenCallback(key, token);\n };\n const handleRemoved = (key, token) => {\n this.clearExpireEventTimeout(key);\n this.emitRemoved(key, token);\n handleTokenCallback(key, token);\n };\n \n const types: TokenType[] = ['idToken', 'accessToken', 'refreshToken'];\n const existingTokens = this.getTokensSync();\n\n // valid tokens\n types.forEach((type) => {\n const token = tokens[type];\n if (token) {\n validateToken(token, type);\n }\n });\n \n // add token to storage\n const storage = types.reduce((storage, type) => {\n const token = tokens[type];\n if (token) {\n const storageKey = this.getStorageKeyByType(type) || type;\n storage[storageKey] = token;\n }\n return storage;\n }, {});\n this.storage.setStorage(storage);\n this.emitSetStorageEvent();\n\n // emit event and start expiration timer\n types.forEach(type => {\n const newToken = tokens[type];\n const existingToken = existingTokens[type];\n const storageKey = this.getStorageKeyByType(type) || type;\n if (newToken && existingToken) { // renew\n // call handleRemoved first, since it clears timers\n handleRemoved(storageKey, existingToken);\n handleAdded(storageKey, newToken);\n handleRenewed(storageKey, newToken, existingToken);\n } else if (newToken) { // add\n handleAdded(storageKey, newToken);\n } else if (existingToken) { //remove\n handleRemoved(storageKey, existingToken);\n }\n });\n }\n \n remove(key) {\n // Clear any listener for this token\n this.clearExpireEventTimeout(key);\n \n var tokenStorage = this.storage.getStorage();\n var removedToken = tokenStorage[key];\n delete tokenStorage[key];\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n \n this.emitRemoved(key, removedToken);\n }\n \n // TODO: this methods is redundant and can be removed in the next major version OKTA-407224\n async renewToken(token) {\n return this.sdk.token?.renew(token);\n }\n // TODO: this methods is redundant and can be removed in the next major version OKTA-407224\n validateToken(token: Token) {\n return validateToken(token);\n }\n\n // TODO: renew method should take no param, change in the next major version OKTA-407224\n renew(key): Promise<Token | undefined> {\n // Multiple callers may receive the same promise. They will all resolve or reject from the same request.\n if (this.state.renewPromise) {\n return this.state.renewPromise;\n }\n \n try {\n var token = this.getSync(key);\n if (!token) {\n throw new AuthSdkError('The tokenManager has no token for the key: ' + key);\n }\n } catch (err) {\n this.emitError(err);\n return Promise.reject(err);\n }\n \n // Remove existing autoRenew timeout\n this.clearExpireEventTimeout(key);\n \n // A refresh token means a replace instead of renewal\n // Store the renew promise state, to avoid renewing again\n const renewPromise = this.state.renewPromise = this.sdk.token.renewTokens()\n .then(tokens => {\n this.setTokens(tokens);\n\n // resolve token based on the key\n const tokenType = this.getTokenType(token!);\n return tokens[tokenType];\n })\n .catch(err => {\n // If renew fails, remove token from storage and emit error\n this.remove(key);\n err.tokenKey = key;\n this.emitError(err);\n throw err;\n })\n .finally(() => {\n // Remove existing promise key\n this.state.renewPromise = null;\n });\n \n return renewPromise;\n }\n \n clear() {\n const tokens = this.getTokensSync();\n this.clearExpireEventTimeoutAll();\n this.storage.clearStorage();\n this.emitSetStorageEvent();\n\n Object.keys(tokens).forEach(key => {\n this.emitRemoved(key, tokens[key]);\n });\n }\n\n clearPendingRemoveTokens() {\n const tokenStorage = this.storage.getStorage();\n const removedTokens = {};\n Object.keys(tokenStorage).forEach(key => {\n if (tokenStorage[key].pendingRemove) {\n removedTokens[key] = tokenStorage[key];\n delete tokenStorage[key];\n }\n });\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n Object.keys(removedTokens).forEach(key => {\n this.clearExpireEventTimeout(key);\n this.emitRemoved(key, removedTokens[key]);\n });\n }\n\n updateRefreshToken(token: RefreshToken) {\n const key = this.getStorageKeyByType('refreshToken') || REFRESH_TOKEN_STORAGE_KEY;\n\n // do not emit any event\n var tokenStorage = this.storage.getStorage();\n validateToken(token);\n tokenStorage[key] = token;\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n }\n\n removeRefreshToken () {\n const key = this.getStorageKeyByType('refreshToken') || REFRESH_TOKEN_STORAGE_KEY;\n this.remove(key);\n }\n\n addPendingRemoveFlags() {\n const tokens = this.getTokensSync();\n Object.keys(tokens).forEach(key => {\n tokens[key].pendingRemove = true;\n });\n this.setTokens(tokens);\n }\n \n}\n"],"mappings":";;;;AAYA;AACA;AACA;AACA;AACA;AACA;AA2BA;AA5CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,MAAMA,eAAe,GAAG;EACtB;EACAC,SAAS,EAAE,IAAI;EACfC,UAAU,EAAE,IAAI;EAChBC,WAAW,EAAE,IAAI;EACjB;EACAC,wBAAwB,EAAE,IAAI;EAC9BC,OAAO,EAAEC,SAAS;EAAE;EACpBC,kBAAkB,EAAE,EAAE;EACtBC,UAAU,EAAEC;AACd,CAAC;AAOD,SAASC,YAAY,GAAsB;EACzC,OAAO;IACLC,cAAc,EAAE,CAAC,CAAC;IAClBC,YAAY,EAAE;EAChB,CAAC;AACH;AACO,MAAMC,YAAY,CAAkC;EAazDC,EAAE,CAACC,KAA2B,EAAEC,OAAoC,EAAEC,OAAgB,EAAQ;IAC5F,IAAIA,OAAO,EAAE;MACX,IAAI,CAACC,OAAO,CAACJ,EAAE,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC;IAC1C,CAAC,MAAM;MACL,IAAI,CAACC,OAAO,CAACJ,EAAE,CAACC,KAAK,EAAEC,OAAO,CAAC;IACjC;EACF;EAOAG,GAAG,CAACJ,KAA2B,EAAEC,OAAqC,EAAQ;IAC5E,IAAIA,OAAO,EAAE;MACX,IAAI,CAACE,OAAO,CAACC,GAAG,CAACJ,KAAK,EAAEC,OAAO,CAAC;IAClC,CAAC,MAAM;MACL,IAAI,CAACE,OAAO,CAACC,GAAG,CAACJ,KAAK,CAAC;IACzB;EACF;;EAEA;EACAK,WAAW,CAACC,GAA2B,EAAEC,OAA4B,GAAG,CAAC,CAA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,CAAC;IAC3C,CAAC,CAAC;EACJ;EAEAiF,kBAAkB,CAACvF,KAAmB,EAAE;IACtC,MAAMM,GAAG,GAAG,IAAI,CAAC6C,mBAAmB,CAAC,cAAc,CAAC,IAAIqC,oCAAyB;;IAEjF;IACA,IAAIxD,YAAY,GAAG,IAAI,CAAC3E,OAAO,CAAC4E,UAAU,EAAE;IAC5C,IAAAG,oBAAa,EAACpC,KAAK,CAAC;IACpBgC,YAAY,CAAC1B,GAAG,CAAC,GAAGN,KAAK;IACzB,IAAI,CAAC3C,OAAO,CAACgF,UAAU,CAACL,YAAY,CAAC;IACrC,IAAI,CAACM,mBAAmB,EAAE;EAC5B;EAEAmD,kBAAkB,GAAI;IACpB,MAAMnF,GAAG,GAAG,IAAI,CAAC6C,mBAAmB,CAAC,cAAc,CAAC,IAAIqC,oCAAyB;IACjF,IAAI,CAAClB,MAAM,CAAChE,GAAG,CAAC;EAClB;EAEAoF,qBAAqB,GAAG;IACtB,MAAMhD,MAAM,GAAG,IAAI,CAACD,aAAa,EAAE;IACnCjE,MAAM,CAACmE,IAAI,CAACD,MAAM,CAAC,CAACE,OAAO,CAACtC,GAAG,IAAI;MACjCoC,MAAM,CAACpC,GAAG,CAAC,CAACgF,aAAa,GAAG,IAAI;IAClC,CAAC,CAAC;IACF,IAAI,CAAC7B,SAAS,CAACf,MAAM,CAAC;EACxB;AAEF;AAAC"}
1
+ {"version":3,"file":"TokenManager.js","names":["DEFAULT_OPTIONS","autoRenew","autoRemove","syncStorage","clearPendingRemoveTokens","storage","undefined","expireEarlySeconds","storageKey","TOKEN_STORAGE_NAME","defaultState","expireTimeouts","renewPromise","TokenManager","on","event","handler","context","emitter","off","constructor","sdk","options","AuthSdkError","Object","assign","removeNils","isLocalhost","storageOptions","secure","storageProvider","storageType","storageManager","getTokenStorage","useSeparateCookies","clock","SdkClock","create","state","start","setExpireEventTimeoutAll","started","stop","clearExpireEventTimeoutAll","isStarted","getOptions","clone","getExpireTime","token","expireTime","expiresAt","hasExpired","now","emitExpired","key","emit","EVENT_EXPIRED","emitRenewed","freshToken","oldToken","EVENT_RENEWED","emitAdded","EVENT_ADDED","emitRemoved","EVENT_REMOVED","emitError","error","EVENT_ERROR","clearExpireEventTimeout","clearTimeout","prototype","hasOwnProperty","call","setExpireEventTimeout","isRefreshToken","expireEventWait","Math","max","expireEventTimeout","setTimeout","tokenStorage","getStorage","resetExpireEventTimeoutAll","add","validateToken","setStorage","emitSetStorageEvent","getSync","get","getTokensSync","tokens","keys","forEach","isAccessToken","accessToken","isIDToken","idToken","refreshToken","getTokens","getStorageKeyByType","type","filter","getTokenType","isIE11OrLess","EVENT_SET_STORAGE","setTokens","accessTokenCb","idTokenCb","refreshTokenCb","handleTokenCallback","handleAdded","handleRenewed","handleRemoved","types","existingTokens","reduce","newToken","existingToken","remove","removedToken","renewToken","renew","shouldRenew","refreshKey","err","Promise","reject","renewTokens","then","tokenType","catch","tokenKey","finally","clear","clearStorage","removedTokens","pendingRemove","updateRefreshToken","REFRESH_TOKEN_STORAGE_KEY","removeRefreshToken","addPendingRemoveFlags"],"sources":["../../../lib/oidc/TokenManager.ts"],"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 { removeNils, clone } from '../util';\nimport { AuthSdkError } from '../errors';\nimport { validateToken } from '../oidc/util';\nimport { isLocalhost, isIE11OrLess } from '../features';\nimport SdkClock from '../clock';\nimport {\n Token, \n Tokens, \n TokenType, \n TokenManagerOptions, \n isIDToken, \n isAccessToken,\n isRefreshToken,\n TokenManagerErrorEventHandler,\n TokenManagerSetStorageEventHandler,\n TokenManagerRenewEventHandler,\n TokenManagerEventHandler,\n TokenManagerInterface,\n RefreshToken,\n AccessTokenCallback,\n IDTokenCallback,\n RefreshTokenCallback,\n EVENT_RENEWED,\n EVENT_ADDED,\n EVENT_ERROR,\n EVENT_EXPIRED,\n EVENT_REMOVED,\n EVENT_SET_STORAGE,\n TokenManagerAnyEventHandler,\n TokenManagerAnyEvent,\n OktaAuthOAuthInterface\n} from './types';\nimport { REFRESH_TOKEN_STORAGE_KEY, TOKEN_STORAGE_NAME } from '../constants';\nimport { EventEmitter } from '../base/types';\nimport { StorageOptions, StorageProvider, StorageType } from '../storage/types';\n\nconst DEFAULT_OPTIONS = {\n // TODO: remove in next major version - OKTA-473815\n autoRenew: true,\n autoRemove: true,\n syncStorage: true,\n // --- //\n clearPendingRemoveTokens: true,\n storage: undefined, // will use value from storageManager config\n expireEarlySeconds: 30,\n storageKey: TOKEN_STORAGE_NAME\n};\n\ninterface TokenManagerState {\n expireTimeouts: Record<string, unknown>;\n renewPromise: Promise<Token | undefined> | null;\n started?: boolean;\n}\nfunction defaultState(): TokenManagerState {\n return {\n expireTimeouts: {},\n renewPromise: null\n };\n}\nexport class TokenManager implements TokenManagerInterface {\n private sdk: OktaAuthOAuthInterface;\n private clock: SdkClock;\n private emitter: EventEmitter;\n private storage: StorageProvider;\n private state: TokenManagerState;\n private options: TokenManagerOptions;\n\n on(event: typeof EVENT_RENEWED, handler: TokenManagerRenewEventHandler, context?: object): void;\n on(event: typeof EVENT_ERROR, handler: TokenManagerErrorEventHandler, context?: object): void;\n on(event: typeof EVENT_SET_STORAGE, handler: TokenManagerSetStorageEventHandler, context?: object): void;\n on(event: typeof EVENT_EXPIRED | typeof EVENT_ADDED | typeof EVENT_REMOVED, \n handler: TokenManagerEventHandler, context?: object): void;\n on(event: TokenManagerAnyEvent, handler: TokenManagerAnyEventHandler, context?: object): void {\n if (context) {\n this.emitter.on(event, handler, context);\n } else {\n this.emitter.on(event, handler);\n }\n }\n\n off(event: typeof EVENT_RENEWED, handler?: TokenManagerRenewEventHandler): void;\n off(event: typeof EVENT_ERROR, handler?: TokenManagerErrorEventHandler): void;\n off(event: typeof EVENT_SET_STORAGE, handler?: TokenManagerSetStorageEventHandler): void;\n off(event: typeof EVENT_EXPIRED | typeof EVENT_ADDED | typeof EVENT_REMOVED, \n handler?: TokenManagerEventHandler): void;\n off(event: TokenManagerAnyEvent, handler?: TokenManagerAnyEventHandler): void {\n if (handler) {\n this.emitter.off(event, handler);\n } else {\n this.emitter.off(event);\n }\n }\n\n // eslint-disable-next-line complexity\n constructor(sdk: OktaAuthOAuthInterface, options: TokenManagerOptions = {}) {\n this.sdk = sdk;\n this.emitter = (sdk as any).emitter;\n if (!this.emitter) {\n throw new AuthSdkError('Emitter should be initialized before TokenManager');\n }\n \n options = Object.assign({}, DEFAULT_OPTIONS, removeNils(options));\n if (!isLocalhost()) {\n options.expireEarlySeconds = DEFAULT_OPTIONS.expireEarlySeconds;\n }\n\n this.options = options;\n\n const storageOptions: StorageOptions = removeNils({\n storageKey: options.storageKey,\n secure: options.secure,\n });\n if (typeof options.storage === 'object') {\n // A custom storage provider must implement getItem(key) and setItem(key, val)\n storageOptions.storageProvider = options.storage;\n } else if (options.storage) {\n storageOptions.storageType = options.storage as StorageType;\n }\n\n this.storage = sdk.storageManager.getTokenStorage({...storageOptions, useSeparateCookies: true});\n this.clock = SdkClock.create(/* sdk, options */);\n this.state = defaultState();\n }\n\n start() {\n if (this.options.clearPendingRemoveTokens) {\n this.clearPendingRemoveTokens();\n }\n this.setExpireEventTimeoutAll();\n this.state.started = true;\n }\n \n stop() {\n this.clearExpireEventTimeoutAll();\n this.state.started = false;\n }\n\n isStarted() {\n return !!this.state.started;\n }\n\n getOptions(): TokenManagerOptions {\n return clone(this.options);\n }\n \n getExpireTime(token) {\n const expireEarlySeconds = this.options.expireEarlySeconds || 0;\n var expireTime = token.expiresAt - expireEarlySeconds;\n return expireTime;\n }\n \n hasExpired(token) {\n var expireTime = this.getExpireTime(token);\n return expireTime <= this.clock.now();\n }\n \n emitExpired(key, token) {\n this.emitter.emit(EVENT_EXPIRED, key, token);\n }\n \n emitRenewed(key, freshToken, oldToken) {\n this.emitter.emit(EVENT_RENEWED, key, freshToken, oldToken);\n }\n \n emitAdded(key, token) {\n this.emitter.emit(EVENT_ADDED, key, token);\n }\n \n emitRemoved(key, token?) {\n this.emitter.emit(EVENT_REMOVED, key, token);\n }\n \n emitError(error) {\n this.emitter.emit(EVENT_ERROR, error);\n }\n \n clearExpireEventTimeout(key) {\n clearTimeout(this.state.expireTimeouts[key] as any);\n delete this.state.expireTimeouts[key];\n \n // Remove the renew promise (if it exists)\n this.state.renewPromise = null;\n }\n \n clearExpireEventTimeoutAll() {\n var expireTimeouts = this.state.expireTimeouts;\n for (var key in expireTimeouts) {\n if (!Object.prototype.hasOwnProperty.call(expireTimeouts, key)) {\n continue;\n }\n this.clearExpireEventTimeout(key);\n }\n }\n \n setExpireEventTimeout(key, token) {\n if (isRefreshToken(token)) {\n return;\n }\n\n var expireTime = this.getExpireTime(token);\n var expireEventWait = Math.max(expireTime - this.clock.now(), 0) * 1000;\n \n // Clear any existing timeout\n this.clearExpireEventTimeout(key);\n \n var expireEventTimeout = setTimeout(() => {\n this.emitExpired(key, token);\n }, expireEventWait);\n \n // Add a new timeout\n this.state.expireTimeouts[key] = expireEventTimeout;\n }\n \n setExpireEventTimeoutAll() {\n var tokenStorage = this.storage.getStorage();\n for(var key in tokenStorage) {\n if (!Object.prototype.hasOwnProperty.call(tokenStorage, key)) {\n continue;\n }\n var token = tokenStorage[key];\n this.setExpireEventTimeout(key, token);\n }\n }\n \n // reset timeouts to setup autoRenew for tokens from other document context (tabs)\n resetExpireEventTimeoutAll() {\n this.clearExpireEventTimeoutAll();\n this.setExpireEventTimeoutAll();\n }\n \n add(key, token: Token) {\n var tokenStorage = this.storage.getStorage();\n validateToken(token);\n tokenStorage[key] = token;\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n this.emitAdded(key, token);\n this.setExpireEventTimeout(key, token);\n }\n \n getSync(key): Token | undefined {\n var tokenStorage = this.storage.getStorage();\n return tokenStorage[key];\n }\n \n async get(key): Promise<Token | undefined> {\n return this.getSync(key);\n }\n \n getTokensSync(): Tokens {\n const tokens = {} as Tokens;\n const tokenStorage = this.storage.getStorage();\n Object.keys(tokenStorage).forEach(key => {\n const token = tokenStorage[key];\n if (isAccessToken(token)) {\n tokens.accessToken = token;\n } else if (isIDToken(token)) {\n tokens.idToken = token;\n } else if (isRefreshToken(token)) { \n tokens.refreshToken = token;\n }\n });\n return tokens;\n }\n \n async getTokens(): Promise<Tokens> {\n return this.getTokensSync();\n }\n\n getStorageKeyByType(type: TokenType): string {\n const tokenStorage = this.storage.getStorage();\n const key = Object.keys(tokenStorage).filter(key => {\n const token = tokenStorage[key];\n return (isAccessToken(token) && type === 'accessToken') \n || (isIDToken(token) && type === 'idToken')\n || (isRefreshToken(token) && type === 'refreshToken');\n })[0];\n return key;\n }\n\n private getTokenType(token: Token): TokenType {\n if (isAccessToken(token)) {\n return 'accessToken';\n }\n if (isIDToken(token)) {\n return 'idToken';\n }\n if(isRefreshToken(token)) {\n return 'refreshToken';\n }\n throw new AuthSdkError('Unknown token type');\n }\n\n // for synchronization of LocalStorage cross tabs for IE11\n private emitSetStorageEvent() {\n if (isIE11OrLess()) {\n const storage = this.storage.getStorage();\n this.emitter.emit(EVENT_SET_STORAGE, storage);\n }\n }\n\n // used in `SyncStorageService` for synchronization of LocalStorage cross tabs for IE11\n public getStorage() {\n return this.storage;\n }\n\n setTokens(\n tokens: Tokens,\n // TODO: callbacks can be removed in the next major version OKTA-407224\n accessTokenCb?: AccessTokenCallback, \n idTokenCb?: IDTokenCallback,\n refreshTokenCb?: RefreshTokenCallback\n ): void {\n const handleTokenCallback = (key, token) => {\n const type = this.getTokenType(token);\n if (type === 'accessToken') {\n accessTokenCb && accessTokenCb(key, token);\n } else if (type === 'idToken') {\n idTokenCb && idTokenCb(key, token);\n } else if (type === 'refreshToken') {\n refreshTokenCb && refreshTokenCb(key, token);\n }\n };\n const handleAdded = (key, token) => {\n this.emitAdded(key, token);\n this.setExpireEventTimeout(key, token);\n handleTokenCallback(key, token);\n };\n const handleRenewed = (key, token, oldToken) => {\n this.emitRenewed(key, token, oldToken);\n this.clearExpireEventTimeout(key);\n this.setExpireEventTimeout(key, token);\n handleTokenCallback(key, token);\n };\n const handleRemoved = (key, token) => {\n this.clearExpireEventTimeout(key);\n this.emitRemoved(key, token);\n handleTokenCallback(key, token);\n };\n \n const types: TokenType[] = ['idToken', 'accessToken', 'refreshToken'];\n const existingTokens = this.getTokensSync();\n\n // valid tokens\n types.forEach((type) => {\n const token = tokens[type];\n if (token) {\n validateToken(token, type);\n }\n });\n \n // add token to storage\n const storage = types.reduce((storage, type) => {\n const token = tokens[type];\n if (token) {\n const storageKey = this.getStorageKeyByType(type) || type;\n storage[storageKey] = token;\n }\n return storage;\n }, {});\n this.storage.setStorage(storage);\n this.emitSetStorageEvent();\n\n // emit event and start expiration timer\n types.forEach(type => {\n const newToken = tokens[type];\n const existingToken = existingTokens[type];\n const storageKey = this.getStorageKeyByType(type) || type;\n if (newToken && existingToken) { // renew\n // call handleRemoved first, since it clears timers\n handleRemoved(storageKey, existingToken);\n handleAdded(storageKey, newToken);\n handleRenewed(storageKey, newToken, existingToken);\n } else if (newToken) { // add\n handleAdded(storageKey, newToken);\n } else if (existingToken) { //remove\n handleRemoved(storageKey, existingToken);\n }\n });\n }\n \n remove(key) {\n // Clear any listener for this token\n this.clearExpireEventTimeout(key);\n \n var tokenStorage = this.storage.getStorage();\n var removedToken = tokenStorage[key];\n delete tokenStorage[key];\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n \n this.emitRemoved(key, removedToken);\n }\n \n // TODO: this methods is redundant and can be removed in the next major version OKTA-407224\n async renewToken(token) {\n return this.sdk.token?.renew(token);\n }\n // TODO: this methods is redundant and can be removed in the next major version OKTA-407224\n validateToken(token: Token) {\n return validateToken(token);\n }\n\n // TODO: renew method should take no param, change in the next major version OKTA-407224\n renew(key): Promise<Token | undefined> {\n // Multiple callers may receive the same promise. They will all resolve or reject from the same request.\n if (this.state.renewPromise) {\n return this.state.renewPromise;\n }\n\n try {\n var token = this.getSync(key);\n let shouldRenew = token !== undefined;\n // explicitly check if key='accessToken' because token keys are not guaranteed (long story, features dragons)\n if (!token && key === 'accessToken') {\n // attempt token renewal if refresh token is present (improves consistency of autoRenew)\n const refreshKey = this.getStorageKeyByType('refreshToken');\n const refreshToken = this.getSync(refreshKey);\n shouldRenew = refreshToken !== undefined;\n }\n\n if (!shouldRenew) {\n throw new AuthSdkError('The tokenManager has no token for the key: ' + key);\n }\n }\n catch (err) {\n this.emitError(err);\n return Promise.reject(err);\n }\n\n // Remove existing autoRenew timeout\n this.clearExpireEventTimeout(key);\n \n // A refresh token means a replace instead of renewal\n // Store the renew promise state, to avoid renewing again\n const renewPromise = this.state.renewPromise = this.sdk.token.renewTokens()\n .then(tokens => {\n this.setTokens(tokens);\n\n // return accessToken in case where access token doesn't exist\n // but refresh token exists\n if (!token && key === 'accessToken') {\n const accessToken = tokens['accessToken'];\n this.emitRenewed(key, accessToken, null);\n return accessToken;\n }\n\n // resolve token based on the key\n const tokenType = this.getTokenType(token!);\n return tokens[tokenType];\n })\n .catch(err => {\n // If renew fails, remove token from storage and emit error\n this.remove(key);\n err.tokenKey = key;\n this.emitError(err);\n throw err;\n })\n .finally(() => {\n // Remove existing promise key\n this.state.renewPromise = null;\n });\n \n return renewPromise;\n }\n \n clear() {\n const tokens = this.getTokensSync();\n this.clearExpireEventTimeoutAll();\n this.storage.clearStorage();\n this.emitSetStorageEvent();\n\n Object.keys(tokens).forEach(key => {\n this.emitRemoved(key, tokens[key]);\n });\n }\n\n clearPendingRemoveTokens() {\n const tokenStorage = this.storage.getStorage();\n const removedTokens = {};\n Object.keys(tokenStorage).forEach(key => {\n if (tokenStorage[key].pendingRemove) {\n removedTokens[key] = tokenStorage[key];\n delete tokenStorage[key];\n }\n });\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n Object.keys(removedTokens).forEach(key => {\n this.clearExpireEventTimeout(key);\n this.emitRemoved(key, removedTokens[key]);\n });\n }\n\n updateRefreshToken(token: RefreshToken) {\n const key = this.getStorageKeyByType('refreshToken') || REFRESH_TOKEN_STORAGE_KEY;\n\n // do not emit any event\n var tokenStorage = this.storage.getStorage();\n validateToken(token);\n tokenStorage[key] = token;\n this.storage.setStorage(tokenStorage);\n this.emitSetStorageEvent();\n }\n\n removeRefreshToken () {\n const key = this.getStorageKeyByType('refreshToken') || REFRESH_TOKEN_STORAGE_KEY;\n this.remove(key);\n }\n\n addPendingRemoveFlags() {\n const tokens = this.getTokensSync();\n Object.keys(tokens).forEach(key => {\n tokens[key].pendingRemove = true;\n });\n this.setTokens(tokens);\n }\n \n}\n"],"mappings":";;;;AAYA;AACA;AACA;AACA;AACA;AACA;AA2BA;AA5CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,MAAMA,eAAe,GAAG;EACtB;EACAC,SAAS,EAAE,IAAI;EACfC,UAAU,EAAE,IAAI;EAChBC,WAAW,EAAE,IAAI;EACjB;EACAC,wBAAwB,EAAE,IAAI;EAC9BC,OAAO,EAAEC,SAAS;EAAE;EACpBC,kBAAkB,EAAE,EAAE;EACtBC,UAAU,EAAEC;AACd,CAAC;AAOD,SAASC,YAAY,GAAsB;EACzC,OAAO;IACLC,cAAc,EAAE,CAAC,CAAC;IAClBC,YAAY,EAAE;EAChB,CAAC;AACH;AACO,MAAMC,YAAY,CAAkC;EAazDC,EAAE,CAACC,KAA2B,EAAEC,OAAoC,EAAEC,OAAgB,EAAQ;IAC5F,IAAIA,OAAO,EAAE;MACX,IAAI,CAACC,OAAO,CAACJ,EAAE,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC;IAC1C,CAAC,MAAM;MACL,IAAI,CAACC,OAAO,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ACrC,IAAI,CAACM,mBAAmB,EAAE;EAC5B;EAEAqD,kBAAkB,GAAI;IACpB,MAAMrF,GAAG,GAAG,IAAI,CAAC6C,mBAAmB,CAAC,cAAc,CAAC,IAAIuC,oCAAyB;IACjF,IAAI,CAACpB,MAAM,CAAChE,GAAG,CAAC;EAClB;EAEAsF,qBAAqB,GAAG;IACtB,MAAMlD,MAAM,GAAG,IAAI,CAACD,aAAa,EAAE;IACnCjE,MAAM,CAACmE,IAAI,CAACD,MAAM,CAAC,CAACE,OAAO,CAACtC,GAAG,IAAI;MACjCoC,MAAM,CAACpC,GAAG,CAAC,CAACkF,aAAa,GAAG,IAAI;IAClC,CAAC,CAAC;IACF,IAAI,CAAC/B,SAAS,CAACf,MAAM,CAAC;EACxB;AAEF;AAAC"}
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+
3
+ exports.clearAllDPoPKeyPairs = clearAllDPoPKeyPairs;
4
+ exports.clearDPoPKeyPair = clearDPoPKeyPair;
5
+ exports.clearDPoPKeyPairAfterRevoke = clearDPoPKeyPairAfterRevoke;
6
+ exports.createDPoPKeyPair = createDPoPKeyPair;
7
+ exports.createJwt = createJwt;
8
+ exports.cryptoRandomValue = cryptoRandomValue;
9
+ exports.findKeyPair = findKeyPair;
10
+ exports.generateDPoPForTokenRequest = generateDPoPForTokenRequest;
11
+ exports.generateDPoPProof = generateDPoPProof;
12
+ exports.generateKeyPair = generateKeyPair;
13
+ exports.isDPoPNonceError = isDPoPNonceError;
14
+ var _crypto = require("../crypto");
15
+ var _errors = require("../errors");
16
+ // References:
17
+ // https://www.w3.org/TR/WebCryptoAPI/#concepts-key-storage
18
+ // https://datatracker.ietf.org/doc/html/rfc9449
19
+
20
+ const INDEXEDDB_NAME = 'OktaAuthJs';
21
+ const DB_KEY = 'DPoPKeys';
22
+ function isDPoPNonceError(obj) {
23
+ return ((0, _errors.isOAuthError)(obj) || (0, _errors.isWWWAuthError)(obj)) && obj.errorCode === 'use_dpop_nonce';
24
+ }
25
+
26
+ /////////// crypto ///////////
27
+
28
+ async function createJwt(header, claims, signingKey) {
29
+ const head = (0, _crypto.stringToBase64Url)(JSON.stringify(header));
30
+ const body = (0, _crypto.stringToBase64Url)(JSON.stringify(claims));
31
+ const signature = await _crypto.webcrypto.subtle.sign({
32
+ name: signingKey.algorithm.name
33
+ }, signingKey, (0, _crypto.stringToBuffer)(`${head}.${body}`));
34
+ return `${head}.${body}.${(0, _crypto.base64ToBase64Url)((0, _crypto.bufferToBase64Url)(signature))}`;
35
+ }
36
+ function cryptoRandomValue(byteLen = 32) {
37
+ return [..._crypto.webcrypto.getRandomValues(new Uint8Array(byteLen))].map(v => v.toString(16)).join('');
38
+ }
39
+ async function generateKeyPair() {
40
+ const algorithm = {
41
+ name: 'RSASSA-PKCS1-v1_5',
42
+ hash: 'SHA-256',
43
+ modulusLength: 2048,
44
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01])
45
+ };
46
+
47
+ // The "false" here makes it non-exportable
48
+ // https://caniuse.com/mdn-api_subtlecrypto_generatekey
49
+ return _crypto.webcrypto.subtle.generateKey(algorithm, false, ['sign', 'verify']);
50
+ }
51
+ async function hashAccessToken(accessToken) {
52
+ const buffer = new TextEncoder().encode(accessToken);
53
+ const hash = await _crypto.webcrypto.subtle.digest('SHA-256', buffer);
54
+ return (0, _crypto.btoa)(String.fromCharCode.apply(null, new Uint8Array(hash))).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
55
+ }
56
+
57
+ /////////// indexeddb / keystore ///////////
58
+
59
+ // https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore#instance_methods
60
+ // add additional methods as needed
61
+
62
+ // convenience abstraction for exposing IDBObjectStore instance
63
+ function keyStore() {
64
+ return new Promise((resolve, reject) => {
65
+ try {
66
+ const indexedDB = window.indexedDB;
67
+ const req = indexedDB.open(INDEXEDDB_NAME, 1);
68
+ req.onerror = function () {
69
+ reject(req.error);
70
+ };
71
+ req.onupgradeneeded = function () {
72
+ const db = req.result;
73
+ db.createObjectStore(DB_KEY);
74
+ };
75
+ req.onsuccess = function () {
76
+ const db = req.result;
77
+ const tx = db.transaction(DB_KEY, 'readwrite');
78
+ tx.onerror = function () {
79
+ reject(tx.error);
80
+ };
81
+ const store = tx.objectStore(DB_KEY);
82
+ resolve(store);
83
+ tx.oncomplete = function () {
84
+ db.close();
85
+ };
86
+ };
87
+ } catch (err) {
88
+ reject(err);
89
+ }
90
+ });
91
+ }
92
+
93
+ // convenience abstraction for wrapping IDBObjectStore methods in promises
94
+ async function invokeStoreMethod(method, ...args) {
95
+ const store = await keyStore();
96
+ return new Promise((resolve, reject) => {
97
+ // https://github.com/microsoft/TypeScript/issues/49700
98
+ // https://github.com/microsoft/TypeScript/issues/49802
99
+ // @ts-expect-error ts(2556)
100
+ const req = store[method](...args);
101
+ req.onsuccess = function () {
102
+ resolve(req);
103
+ };
104
+ req.onerror = function () {
105
+ reject(req.error);
106
+ };
107
+ });
108
+ }
109
+ async function storeKeyPair(pairId, keyPair) {
110
+ await invokeStoreMethod('add', keyPair, pairId);
111
+ return keyPair;
112
+ }
113
+
114
+ // attempts to find keyPair stored at given key, otherwise throws
115
+ async function findKeyPair(pairId) {
116
+ if (pairId) {
117
+ const req = await invokeStoreMethod('get', pairId);
118
+ if (req.result) {
119
+ return req.result;
120
+ }
121
+ }
122
+
123
+ // defaults to throwing unless keyPair is found
124
+ throw new _errors.AuthSdkError(`Unable to locate dpop key pair required for refresh${pairId ? ` (${pairId})` : ''}`);
125
+ }
126
+ async function clearDPoPKeyPair(pairId) {
127
+ await invokeStoreMethod('delete', pairId);
128
+ }
129
+ async function clearAllDPoPKeyPairs() {
130
+ await invokeStoreMethod('clear');
131
+ }
132
+
133
+ // generates a crypto (non-extractable) private key pair and writes it to indexeddb, returns key (id)
134
+ async function createDPoPKeyPair() {
135
+ const keyPairId = cryptoRandomValue(4);
136
+ const keyPair = await generateKeyPair();
137
+ await storeKeyPair(keyPairId, keyPair);
138
+ return {
139
+ keyPair,
140
+ keyPairId
141
+ };
142
+ }
143
+
144
+ // will clear PK from storage if certain token conditions are met
145
+ /* eslint max-len: [2, 132], complexity: [2, 12] */
146
+ async function clearDPoPKeyPairAfterRevoke(revokedToken, tokens) {
147
+ let shouldClear = false;
148
+ const {
149
+ accessToken,
150
+ refreshToken
151
+ } = tokens;
152
+
153
+ // revoking access token and refresh token doesn't exist
154
+ if (revokedToken === 'access' && accessToken && accessToken.tokenType === 'DPoP' && !refreshToken) {
155
+ shouldClear = true;
156
+ }
157
+
158
+ // revoking refresh token and access token doesn't exist
159
+ if (revokedToken === 'refresh' && refreshToken && !accessToken) {
160
+ shouldClear = true;
161
+ }
162
+ const pairId = accessToken?.dpopPairId ?? refreshToken?.dpopPairId;
163
+ if (shouldClear && pairId) {
164
+ await clearDPoPKeyPair(pairId);
165
+ }
166
+ }
167
+
168
+ /////////// proof generation methods ///////////
169
+
170
+ async function generateDPoPProof({
171
+ keyPair,
172
+ url,
173
+ method,
174
+ nonce,
175
+ accessToken
176
+ }) {
177
+ const {
178
+ kty,
179
+ crv,
180
+ e,
181
+ n,
182
+ x,
183
+ y
184
+ } = await _crypto.webcrypto.subtle.exportKey('jwk', keyPair.publicKey);
185
+ const header = {
186
+ alg: 'RS256',
187
+ typ: 'dpop+jwt',
188
+ jwk: {
189
+ kty,
190
+ crv,
191
+ e,
192
+ n,
193
+ x,
194
+ y
195
+ }
196
+ };
197
+ const claims = {
198
+ htm: method,
199
+ htu: url,
200
+ iat: Math.floor(Date.now() / 1000),
201
+ jti: cryptoRandomValue()
202
+ };
203
+ if (nonce) {
204
+ claims.nonce = nonce;
205
+ }
206
+
207
+ // encode access token
208
+ if (accessToken) {
209
+ claims.ath = await hashAccessToken(accessToken);
210
+ }
211
+ return createJwt(header, claims, keyPair.privateKey);
212
+ }
213
+
214
+ /* eslint max-len: [2, 132] */
215
+ async function generateDPoPForTokenRequest({
216
+ keyPair,
217
+ url,
218
+ method,
219
+ nonce
220
+ }) {
221
+ const params = {
222
+ keyPair,
223
+ url,
224
+ method
225
+ };
226
+ if (nonce) {
227
+ params.nonce = nonce;
228
+ }
229
+ return generateDPoPProof(params);
230
+ }
231
+ //# sourceMappingURL=dpop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dpop.js","names":["INDEXEDDB_NAME","DB_KEY","isDPoPNonceError","obj","isOAuthError","isWWWAuthError","errorCode","createJwt","header","claims","signingKey","head","stringToBase64Url","JSON","stringify","body","signature","webcrypto","subtle","sign","name","algorithm","stringToBuffer","base64ToBase64Url","bufferToBase64Url","cryptoRandomValue","byteLen","getRandomValues","Uint8Array","map","v","toString","join","generateKeyPair","hash","modulusLength","publicExponent","generateKey","hashAccessToken","accessToken","buffer","TextEncoder","encode","digest","btoa","String","fromCharCode","apply","replace","keyStore","Promise","resolve","reject","indexedDB","window","req","open","onerror","error","onupgradeneeded","db","result","createObjectStore","onsuccess","tx","transaction","store","objectStore","oncomplete","close","err","invokeStoreMethod","method","args","storeKeyPair","pairId","keyPair","findKeyPair","AuthSdkError","clearDPoPKeyPair","clearAllDPoPKeyPairs","createDPoPKeyPair","keyPairId","clearDPoPKeyPairAfterRevoke","revokedToken","tokens","shouldClear","refreshToken","tokenType","dpopPairId","generateDPoPProof","url","nonce","kty","crv","e","n","x","y","exportKey","publicKey","alg","typ","jwk","htm","htu","iat","Math","floor","Date","now","jti","ath","privateKey","generateDPoPForTokenRequest","params"],"sources":["../../../lib/oidc/dpop.ts"],"sourcesContent":["// References:\n// https://www.w3.org/TR/WebCryptoAPI/#concepts-key-storage\n// https://datatracker.ietf.org/doc/html/rfc9449\n\nimport {\n webcrypto,\n stringToBase64Url,\n stringToBuffer,\n bufferToBase64Url,\n base64ToBase64Url,\n btoa\n} from '../crypto';\nimport { AuthSdkError, OAuthError, WWWAuthError, isOAuthError, isWWWAuthError } from '../errors';\nimport { Tokens } from './types';\n\nexport interface DPoPClaims {\n htm: string;\n htu: string;\n iat: number;\n jti: string;\n nonce?: string;\n ath?: string;\n}\n\nexport interface DPoPProofParams {\n keyPair: CryptoKeyPair;\n url: string;\n method: string;\n nonce?: string;\n accessToken?: string;\n}\n\nexport type ResourceDPoPProofParams = Omit<DPoPProofParams, 'keyPair' | 'nonce'>;\ntype DPoPProofTokenRequestParams = Omit<DPoPProofParams, 'accessToken'>;\n\nconst INDEXEDDB_NAME = 'OktaAuthJs';\nconst DB_KEY = 'DPoPKeys';\n\nexport function isDPoPNonceError(obj: any): obj is OAuthError | WWWAuthError {\n return (\n (isOAuthError(obj) || isWWWAuthError(obj)) &&\n obj.errorCode === 'use_dpop_nonce'\n );\n}\n\n/////////// crypto ///////////\n\nexport async function createJwt(header: object, claims: object, signingKey: CryptoKey): Promise<string> {\n const head = stringToBase64Url(JSON.stringify(header));\n const body = stringToBase64Url(JSON.stringify(claims));\n const signature = await webcrypto.subtle.sign(\n { name: signingKey.algorithm.name }, signingKey, stringToBuffer(`${head}.${body}`)\n );\n return `${head}.${body}.${base64ToBase64Url(bufferToBase64Url(signature))}`;\n}\n\nexport function cryptoRandomValue (byteLen = 32) {\n return [...webcrypto.getRandomValues(new Uint8Array(byteLen))].map(v => v.toString(16)).join('');\n}\n\nexport async function generateKeyPair (): Promise<CryptoKeyPair> {\n const algorithm = {\n name: 'RSASSA-PKCS1-v1_5',\n hash: 'SHA-256',\n modulusLength: 2048,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n };\n\n // The \"false\" here makes it non-exportable\n // https://caniuse.com/mdn-api_subtlecrypto_generatekey\n return webcrypto.subtle.generateKey(algorithm, false, ['sign', 'verify']);\n}\n\nasync function hashAccessToken (accessToken: string): Promise<string> {\n const buffer = new TextEncoder().encode(accessToken);\n const hash = await webcrypto.subtle.digest('SHA-256', buffer);\n\n return btoa(String.fromCharCode.apply(null, new Uint8Array(hash) as unknown as number[]))\n .replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\n/////////// indexeddb / keystore ///////////\n\n\n// https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore#instance_methods\n// add additional methods as needed\nexport type StoreMethod = 'get' | 'add' | 'delete' | 'clear';\n\n// convenience abstraction for exposing IDBObjectStore instance\nfunction keyStore (): Promise<IDBObjectStore> {\n return new Promise((resolve, reject) => {\n try {\n const indexedDB = window.indexedDB;\n const req = indexedDB.open(INDEXEDDB_NAME, 1);\n\n req.onerror = function () {\n reject(req.error!);\n };\n\n req.onupgradeneeded = function () {\n const db = req.result;\n db.createObjectStore(DB_KEY);\n };\n\n req.onsuccess = function () {\n const db = req.result;\n const tx = db.transaction(DB_KEY, 'readwrite');\n\n tx.onerror = function () {\n reject(tx.error!);\n };\n\n const store = tx.objectStore(DB_KEY);\n\n resolve(store);\n\n tx.oncomplete = function () {\n db.close();\n };\n };\n }\n catch (err) {\n reject(err);\n }\n });\n}\n\n// convenience abstraction for wrapping IDBObjectStore methods in promises\nasync function invokeStoreMethod (method: StoreMethod, ...args: any[]): Promise<IDBRequest> {\n const store = await keyStore();\n return new Promise((resolve, reject) => {\n // https://github.com/microsoft/TypeScript/issues/49700\n // https://github.com/microsoft/TypeScript/issues/49802\n // @ts-expect-error ts(2556)\n const req = store[method](...args);\n req.onsuccess = function () {\n resolve(req);\n };\n req.onerror = function () {\n reject(req.error);\n };\n });\n}\n\nasync function storeKeyPair (pairId: string, keyPair: CryptoKeyPair) {\n await invokeStoreMethod('add', keyPair, pairId);\n return keyPair;\n}\n\n// attempts to find keyPair stored at given key, otherwise throws\nexport async function findKeyPair (pairId?: string): Promise<CryptoKeyPair> {\n if (pairId) {\n const req = await invokeStoreMethod('get', pairId);\n if (req.result) {\n return req.result;\n }\n }\n\n // defaults to throwing unless keyPair is found\n throw new AuthSdkError(`Unable to locate dpop key pair required for refresh${pairId ? ` (${pairId})` : ''}`);\n}\n\nexport async function clearDPoPKeyPair (pairId: string): Promise<void> {\n await invokeStoreMethod('delete', pairId);\n}\n\nexport async function clearAllDPoPKeyPairs (): Promise<void> {\n await invokeStoreMethod('clear');\n}\n\n// generates a crypto (non-extractable) private key pair and writes it to indexeddb, returns key (id)\nexport async function createDPoPKeyPair (): Promise<{keyPair: CryptoKeyPair, keyPairId: string}> {\n const keyPairId = cryptoRandomValue(4);\n const keyPair = await generateKeyPair();\n await storeKeyPair(keyPairId, keyPair);\n return { keyPair, keyPairId };\n}\n\n// will clear PK from storage if certain token conditions are met\n/* eslint max-len: [2, 132], complexity: [2, 12] */\nexport async function clearDPoPKeyPairAfterRevoke (revokedToken: 'access' | 'refresh', tokens: Tokens): Promise<void> {\n let shouldClear = false;\n\n const { accessToken, refreshToken } = tokens;\n\n // revoking access token and refresh token doesn't exist\n if (revokedToken === 'access' && accessToken && accessToken.tokenType === 'DPoP' && !refreshToken) {\n shouldClear = true;\n }\n\n // revoking refresh token and access token doesn't exist\n if (revokedToken === 'refresh' && refreshToken && !accessToken) {\n shouldClear = true;\n }\n\n const pairId = accessToken?.dpopPairId ?? refreshToken?.dpopPairId;\n if (shouldClear && pairId) {\n await clearDPoPKeyPair(pairId);\n }\n}\n\n/////////// proof generation methods ///////////\n\nexport async function generateDPoPProof ({ keyPair, url, method, nonce, accessToken }: DPoPProofParams): Promise<string> {\n const { kty, crv, e, n, x, y } = await webcrypto.subtle.exportKey('jwk', keyPair.publicKey);\n const header = {\n alg: 'RS256',\n typ: 'dpop+jwt',\n jwk: { kty, crv, e, n, x, y }\n };\n\n const claims: DPoPClaims = {\n htm: method,\n htu: url,\n iat: Math.floor(Date.now() / 1000),\n jti: cryptoRandomValue(),\n };\n\n if (nonce) {\n claims.nonce = nonce;\n }\n\n // encode access token\n if (accessToken) {\n claims.ath = await hashAccessToken(accessToken);\n }\n\n return createJwt(header, claims, keyPair.privateKey);\n}\n\n/* eslint max-len: [2, 132] */\nexport async function generateDPoPForTokenRequest ({ keyPair, url, method, nonce }: DPoPProofTokenRequestParams): Promise<string> {\n const params: DPoPProofParams = { keyPair, url, method };\n if (nonce) {\n params.nonce = nonce;\n }\n\n return generateDPoPProof(params);\n}\n"],"mappings":";;;;;;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AAiB,CAACyB,MAAM,CAAC;AAClC"}
@@ -5,6 +5,7 @@ exports.postToTokenEndpoint = postToTokenEndpoint;
5
5
  var _errors = require("../../errors");
6
6
  var _util = require("../../util");
7
7
  var _http = require("../../http");
8
+ var _dpop = require("../dpop");
8
9
  /*!
9
10
  * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
10
11
  * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
@@ -56,38 +57,87 @@ function getPostData(sdk, options) {
56
57
  return (0, _util.toQueryString)(params).slice(1);
57
58
  }
58
59
 
59
- // exchange authorization code for an access token
60
- function postToTokenEndpoint(sdk, options, urls) {
61
- validateOptions(options);
62
- var data = getPostData(sdk, options);
60
+ /* eslint complexity: [2, 10] */
61
+ async function makeTokenRequest(sdk, {
62
+ url,
63
+ data,
64
+ nonce,
65
+ dpopKeyPair
66
+ }) {
67
+ const method = 'POST';
63
68
  const headers = {
64
69
  'Content-Type': 'application/x-www-form-urlencoded'
65
70
  };
66
- return (0, _http.httpRequest)(sdk, {
71
+ if (sdk.options.dpop) {
72
+ if (!dpopKeyPair) {
73
+ throw new _errors.AuthSdkError('DPoP is configured but no key pair was provided');
74
+ }
75
+ const proof = await (0, _dpop.generateDPoPForTokenRequest)({
76
+ url,
77
+ method,
78
+ nonce,
79
+ keyPair: dpopKeyPair
80
+ });
81
+ headers.DPoP = proof;
82
+ }
83
+ try {
84
+ const resp = await (0, _http.httpRequest)(sdk, {
85
+ url,
86
+ method,
87
+ args: data,
88
+ headers
89
+ });
90
+ return resp;
91
+ } catch (err) {
92
+ if ((0, _dpop.isDPoPNonceError)(err) && !nonce) {
93
+ const dpopNonce = err.resp?.headers['dpop-nonce'];
94
+ if (!dpopNonce) {
95
+ // throws error is dpop-nonce header cannot be found, prevents infinite loop
96
+ throw new _errors.AuthApiError({
97
+ errorSummary: 'No `dpop-nonce` header found when required'
98
+ }, err.resp ?? undefined // yay ts
99
+ );
100
+ }
101
+
102
+ return makeTokenRequest(sdk, {
103
+ url,
104
+ data,
105
+ dpopKeyPair,
106
+ nonce: dpopNonce
107
+ });
108
+ }
109
+ throw err;
110
+ }
111
+ }
112
+
113
+ // exchange authorization code for an access token
114
+ async function postToTokenEndpoint(sdk, options, urls) {
115
+ validateOptions(options);
116
+ var data = getPostData(sdk, options);
117
+ const params = {
67
118
  url: urls.tokenUrl,
68
- method: 'POST',
69
- args: data,
70
- headers
71
- });
119
+ data,
120
+ dpopKeyPair: options?.dpopKeyPair
121
+ };
122
+ return makeTokenRequest(sdk, params);
72
123
  }
73
- function postRefreshToken(sdk, options, refreshToken) {
74
- return (0, _http.httpRequest)(sdk, {
124
+ async function postRefreshToken(sdk, options, refreshToken) {
125
+ const data = Object.entries({
126
+ client_id: options.clientId,
127
+ // eslint-disable-line camelcase
128
+ grant_type: 'refresh_token',
129
+ // eslint-disable-line camelcase
130
+ scope: refreshToken.scopes.join(' '),
131
+ refresh_token: refreshToken.refreshToken // eslint-disable-line camelcase
132
+ }).map(function ([name, value]) {
133
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
134
+ return name + '=' + encodeURIComponent(value);
135
+ }).join('&');
136
+ const params = {
75
137
  url: refreshToken.tokenUrl,
76
- method: 'POST',
77
- headers: {
78
- 'Content-Type': 'application/x-www-form-urlencoded'
79
- },
80
- args: Object.entries({
81
- client_id: options.clientId,
82
- // eslint-disable-line camelcase
83
- grant_type: 'refresh_token',
84
- // eslint-disable-line camelcase
85
- scope: refreshToken.scopes.join(' '),
86
- refresh_token: refreshToken.refreshToken // eslint-disable-line camelcase
87
- }).map(function ([name, value]) {
88
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
89
- return name + '=' + encodeURIComponent(value);
90
- }).join('&')
91
- });
138
+ data,
139
+ dpopKeyPair: options?.dpopKeyPair
140
+ };
141
+ return makeTokenRequest(sdk, params);
92
142
  }
93
143
  //# sourceMappingURL=token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.js","names":["validateOptions","options","clientId","AuthSdkError","redirectUri","authorizationCode","interactionCode","codeVerifier","getPostData","sdk","params","removeNils","code","clientSecret","toQueryString","slice","postToTokenEndpoint","urls","data","headers","httpRequest","url","tokenUrl","method","args","postRefreshToken","refreshToken","Object","entries","client_id","grant_type","scope","scopes","join","refresh_token","map","name","value","encodeURIComponent"],"sources":["../../../../lib/oidc/endpoints/token.ts"],"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 { CustomUrls, OAuthParams, OAuthResponse, RefreshToken, TokenParams } from '../types';\nimport { removeNils, toQueryString } from '../../util';\nimport { httpRequest, OktaAuthHttpInterface } from '../../http';\n\nfunction validateOptions(options: TokenParams) {\n // Quick validation\n if (!options.clientId) {\n throw new AuthSdkError('A clientId must be specified in the OktaAuth constructor to get a token');\n }\n\n if (!options.redirectUri) {\n throw new AuthSdkError('The redirectUri passed to /authorize must also be passed to /token');\n }\n\n if (!options.authorizationCode && !options.interactionCode) {\n throw new AuthSdkError('An authorization code (returned from /authorize) must be passed to /token');\n }\n\n if (!options.codeVerifier) {\n throw new AuthSdkError('The \"codeVerifier\" (generated and saved by your app) must be passed to /token');\n }\n}\n\nfunction getPostData(sdk, options: TokenParams): string {\n // Convert Token params to OAuth params, sent to the /token endpoint\n var params: OAuthParams = removeNils({\n 'client_id': options.clientId,\n 'redirect_uri': options.redirectUri,\n 'grant_type': options.interactionCode ? 'interaction_code' : 'authorization_code',\n 'code_verifier': options.codeVerifier\n });\n\n if (options.interactionCode) {\n params['interaction_code'] = options.interactionCode;\n } else if (options.authorizationCode) {\n params.code = options.authorizationCode;\n }\n\n const { clientSecret } = sdk.options;\n if (clientSecret) {\n params['client_secret'] = clientSecret;\n }\n\n // Encode as URL string\n return toQueryString(params).slice(1);\n}\n\n// exchange authorization code for an access token\nexport function postToTokenEndpoint(sdk, options: TokenParams, urls: CustomUrls): Promise<OAuthResponse> {\n validateOptions(options);\n var data = getPostData(sdk, options);\n\n const headers = {\n 'Content-Type': 'application/x-www-form-urlencoded'\n };\n\n return httpRequest(sdk, {\n url: urls.tokenUrl,\n method: 'POST',\n args: data,\n headers\n });\n}\n\nexport function postRefreshToken(\n sdk: OktaAuthHttpInterface,\n options: TokenParams,\n refreshToken: RefreshToken\n): Promise<OAuthResponse> {\n return httpRequest(sdk, {\n url: refreshToken.tokenUrl,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n\n args: Object.entries({\n client_id: options.clientId, // eslint-disable-line camelcase\n grant_type: 'refresh_token', // eslint-disable-line camelcase\n scope: refreshToken.scopes.join(' '),\n refresh_token: refreshToken.refreshToken, // eslint-disable-line camelcase\n }).map(function ([name, value]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return name + '=' + encodeURIComponent(value!);\n }).join('&'),\n });\n}"],"mappings":";;;;AAaA;AAEA;AACA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,eAAe,CAACC,OAAoB,EAAE;EAC7C;EACA,IAAI,CAACA,OAAO,CAACC,QAAQ,EAAE;IACrB,MAAM,IAAIC,oBAAY,CAAC,yEAAyE,CAAC;EACnG;EAEA,IAAI,CAACF,OAAO,CAACG,WAAW,EAAE;IACxB,MAAM,IAAID,oBAAY,CAAC,oEAAoE,CAAC;EAC9F;EAEA,IAAI,CAACF,OAAO,CAACI,iBAAiB,IAAI,CAACJ,OAAO,CAACK,eAAe,EAAE;IAC1D,MAAM,IAAIH,oBAAY,CAAC,2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J;AAEO,SAASM,gBAAgB,CAC9BhB,GAA0B,EAC1BR,OAAoB,EACpByB,YAA0B,EACF;EACxB,OAAO,IAAAN,iBAAW,EAACX,GAAG,EAAE;IACtBY,GAAG,EAAEK,YAAY,CAACJ,QAAQ;IAC1BC,MAAM,EAAE,MAAM;IACdJ,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IAEDK,IAAI,EAAEG,MAAM,CAACC,OAAO,CAAC;MACnBC,SAAS,EAAE5B,OAAO,CAACC,QAAQ;MAAE;MAC7B4B,UAAU,EAAE,eAAe;MAAE;MAC7BC,KAAK,EAAEL,YAAY,CAACM,MAAM,CAACC,IAAI,CAAC,GAAG,CAAC;MACpCC,aAAa,EAAER,YAAY,CAACA,YAAY,CAAE;IAC5C,CAAC,CAAC,CAACS,GAAG,CAAC,UAAU,CAACC,IAAI,EAAEC,KAAK,CAAC,EAAE;MAC9B;MACA,OAAOD,IAAI,GAAG,GAAG,GAAGE,kBAAkB,CAACD,KAAK,CAAE;IAChD,CAAC,CAAC,CAACJ,IAAI,CAAC,GAAG;EACb,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"token.js","names":["validateOptions","options","clientId","AuthSdkError","redirectUri","authorizationCode","interactionCode","codeVerifier","getPostData","sdk","params","removeNils","code","clientSecret","toQueryString","slice","makeTokenRequest","url","data","nonce","dpopKeyPair","method","headers","dpop","proof","generateDPoPForTokenRequest","keyPair","DPoP","resp","httpRequest","args","err","isDPoPNonceError","dpopNonce","AuthApiError","errorSummary","undefined","postToTokenEndpoint","urls","tokenUrl","postRefreshToken","refreshToken","Object","entries","client_id","grant_type","scope","scopes","join","refresh_token","map","name","value","encodeURIComponent"],"sources":["../../../../lib/oidc/endpoints/token.ts"],"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, AuthApiError } from '../../errors';\nimport { CustomUrls, OAuthParams, OAuthResponse, RefreshToken, TokenParams } from '../types';\nimport { removeNils, toQueryString } from '../../util';\nimport { httpRequest, OktaAuthHttpInterface } from '../../http';\nimport { generateDPoPForTokenRequest, isDPoPNonceError } from '../dpop';\n\nexport interface TokenEndpointParams extends TokenParams {\n dpopKeyPair?: CryptoKeyPair;\n}\n\ninterface TokenRequestParams {\n url: string;\n data: any;\n dpopKeyPair?: CryptoKeyPair;\n nonce?: string;\n}\n\nfunction validateOptions(options: TokenEndpointParams) {\n // Quick validation\n if (!options.clientId) {\n throw new AuthSdkError('A clientId must be specified in the OktaAuth constructor to get a token');\n }\n\n if (!options.redirectUri) {\n throw new AuthSdkError('The redirectUri passed to /authorize must also be passed to /token');\n }\n\n if (!options.authorizationCode && !options.interactionCode) {\n throw new AuthSdkError('An authorization code (returned from /authorize) must be passed to /token');\n }\n\n if (!options.codeVerifier) {\n throw new AuthSdkError('The \"codeVerifier\" (generated and saved by your app) must be passed to /token');\n }\n}\n\nfunction getPostData(sdk, options: TokenParams): string {\n // Convert Token params to OAuth params, sent to the /token endpoint\n var params: OAuthParams = removeNils({\n 'client_id': options.clientId,\n 'redirect_uri': options.redirectUri,\n 'grant_type': options.interactionCode ? 'interaction_code' : 'authorization_code',\n 'code_verifier': options.codeVerifier\n });\n\n if (options.interactionCode) {\n params['interaction_code'] = options.interactionCode;\n } else if (options.authorizationCode) {\n params.code = options.authorizationCode;\n }\n\n const { clientSecret } = sdk.options;\n if (clientSecret) {\n params['client_secret'] = clientSecret;\n }\n\n // Encode as URL string\n return toQueryString(params).slice(1);\n}\n\n/* eslint complexity: [2, 10] */\nasync function makeTokenRequest (sdk, { url, data, nonce, dpopKeyPair }: TokenRequestParams): Promise<OAuthResponse> {\n const method = 'POST';\n const headers: any = {\n 'Content-Type': 'application/x-www-form-urlencoded',\n };\n\n if (sdk.options.dpop) {\n if (!dpopKeyPair) {\n throw new AuthSdkError('DPoP is configured but no key pair was provided');\n }\n\n const proof = await generateDPoPForTokenRequest({ url, method, nonce, keyPair: dpopKeyPair });\n headers.DPoP = proof;\n }\n\n try {\n const resp = await httpRequest(sdk, {\n url,\n method,\n args: data,\n headers\n });\n return resp;\n }\n catch (err) {\n if (isDPoPNonceError(err) && !nonce) {\n const dpopNonce = err.resp?.headers['dpop-nonce'];\n if (!dpopNonce) {\n // throws error is dpop-nonce header cannot be found, prevents infinite loop\n throw new AuthApiError(\n {errorSummary: 'No `dpop-nonce` header found when required'},\n err.resp ?? undefined // yay ts\n );\n }\n return makeTokenRequest(sdk, { url, data, dpopKeyPair, nonce: dpopNonce });\n }\n throw err;\n }\n}\n\n// exchange authorization code for an access token\nexport async function postToTokenEndpoint(sdk, options: TokenEndpointParams, urls: CustomUrls): Promise<OAuthResponse> {\n validateOptions(options);\n var data = getPostData(sdk, options);\n\n const params: TokenRequestParams = {\n url: urls.tokenUrl!,\n data,\n dpopKeyPair: options?.dpopKeyPair\n };\n\n return makeTokenRequest(sdk, params);\n}\n\nexport async function postRefreshToken(\n sdk: OktaAuthHttpInterface,\n options: TokenEndpointParams,\n refreshToken: RefreshToken\n): Promise<OAuthResponse> {\n const data = Object.entries({\n client_id: options.clientId, // eslint-disable-line camelcase\n grant_type: 'refresh_token', // eslint-disable-line camelcase\n scope: refreshToken.scopes.join(' '),\n refresh_token: refreshToken.refreshToken, // eslint-disable-line camelcase\n }).map(function ([name, value]) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return name + '=' + encodeURIComponent(value!);\n }).join('&');\n\n const params: TokenRequestParams = {\n url: refreshToken.tokenUrl,\n data,\n dpopKeyPair: options?.dpopKeyPair\n };\n\n return makeTokenRequest(sdk, params);\n}\n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