@okta/okta-auth-js 5.11.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +63 -29
  3. package/cjs/AuthStateManager.js +15 -6
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +168 -108
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/OktaUserAgent.js.map +1 -1
  9. package/cjs/PromiseQueue.js +11 -2
  10. package/cjs/PromiseQueue.js.map +1 -1
  11. package/cjs/SavedObject.js +4 -2
  12. package/cjs/SavedObject.js.map +1 -1
  13. package/cjs/ServiceManager.js +195 -0
  14. package/cjs/ServiceManager.js.map +1 -0
  15. package/cjs/StorageManager.js +16 -9
  16. package/cjs/StorageManager.js.map +1 -1
  17. package/cjs/TokenManager.js +42 -34
  18. package/cjs/TokenManager.js.map +1 -1
  19. package/cjs/TransactionManager.js +26 -7
  20. package/cjs/TransactionManager.js.map +1 -1
  21. package/cjs/browser/browserStorage.js +36 -20
  22. package/cjs/browser/browserStorage.js.map +1 -1
  23. package/cjs/browser/fingerprint.js +12 -4
  24. package/cjs/browser/fingerprint.js.map +1 -1
  25. package/cjs/builderUtil.js +7 -19
  26. package/cjs/builderUtil.js.map +1 -1
  27. package/cjs/clock.js +5 -1
  28. package/cjs/clock.js.map +1 -1
  29. package/cjs/crypto/base64.js +18 -0
  30. package/cjs/crypto/base64.js.map +1 -1
  31. package/cjs/crypto/index.js +6 -4
  32. package/cjs/crypto/index.js.map +1 -1
  33. package/cjs/crypto/node.js +19 -13
  34. package/cjs/crypto/node.js.map +1 -1
  35. package/cjs/crypto/oidcHash.js +5 -1
  36. package/cjs/crypto/oidcHash.js.map +1 -1
  37. package/cjs/crypto/webauthn.js +101 -0
  38. package/cjs/crypto/webauthn.js.map +1 -0
  39. package/cjs/crypto/webcrypto.js +3 -1
  40. package/cjs/crypto/webcrypto.js.map +1 -1
  41. package/cjs/errors/AuthApiError.js +1 -1
  42. package/cjs/errors/AuthPollStopError.js +1 -1
  43. package/cjs/errors/AuthSdkError.js +1 -1
  44. package/cjs/errors/CustomError.js +5 -1
  45. package/cjs/errors/CustomError.js.map +1 -1
  46. package/cjs/errors/OAuthError.js +1 -1
  47. package/cjs/errors/index.js +1 -1
  48. package/cjs/features.js +9 -3
  49. package/cjs/features.js.map +1 -1
  50. package/cjs/fetch/fetchRequest.js +19 -6
  51. package/cjs/fetch/fetchRequest.js.map +1 -1
  52. package/cjs/http/headers.js.map +1 -1
  53. package/cjs/http/index.js +4 -2
  54. package/cjs/http/index.js.map +1 -1
  55. package/cjs/http/request.js +11 -5
  56. package/cjs/http/request.js.map +1 -1
  57. package/cjs/idx/authenticate.js +8 -5
  58. package/cjs/idx/authenticate.js.map +1 -1
  59. package/cjs/idx/authenticator/Authenticator.js.map +1 -1
  60. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  61. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +1 -1
  62. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
  63. package/cjs/idx/authenticator/SecurityQuestionVerification.js +2 -1
  64. package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
  65. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +2 -2
  66. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
  67. package/cjs/idx/authenticator/WebauthnEnrollment.js +46 -0
  68. package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -0
  69. package/cjs/idx/authenticator/WebauthnVerification.js +55 -0
  70. package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -0
  71. package/cjs/idx/authenticator/getAuthenticator.js +17 -6
  72. package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
  73. package/cjs/idx/authenticator/index.js +34 -6
  74. package/cjs/idx/authenticator/index.js.map +1 -1
  75. package/cjs/idx/cancel.js.map +1 -1
  76. package/cjs/idx/emailVerify.js +73 -0
  77. package/cjs/idx/emailVerify.js.map +1 -0
  78. package/cjs/idx/flow/AccountUnlockFlow.js +30 -0
  79. package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -0
  80. package/cjs/idx/flow/FlowSpecification.js +24 -4
  81. package/cjs/idx/flow/FlowSpecification.js.map +1 -1
  82. package/cjs/idx/flow/PasswordRecoveryFlow.js +4 -1
  83. package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -1
  84. package/cjs/idx/flow/RegistrationFlow.js +2 -0
  85. package/cjs/idx/flow/RegistrationFlow.js.map +1 -1
  86. package/cjs/idx/flow/index.js +20 -5
  87. package/cjs/idx/flow/index.js.map +1 -1
  88. package/cjs/idx/handleInteractionCodeRedirect.js +6 -1
  89. package/cjs/idx/handleInteractionCodeRedirect.js.map +1 -1
  90. package/cjs/idx/headers.js +21 -5
  91. package/cjs/idx/headers.js.map +1 -1
  92. package/cjs/idx/idx-js/client.js +91 -0
  93. package/cjs/idx/idx-js/client.js.map +1 -0
  94. package/cjs/idx/idx-js/index.js +162 -0
  95. package/cjs/idx/idx-js/index.js.map +1 -0
  96. package/cjs/idx/idx-js/interact.js +83 -0
  97. package/cjs/idx/idx-js/interact.js.map +1 -0
  98. package/cjs/idx/idx-js/introspect.js +58 -0
  99. package/cjs/idx/idx-js/introspect.js.map +1 -0
  100. package/cjs/idx/idx-js/parsers.js +41 -0
  101. package/cjs/idx/idx-js/parsers.js.map +1 -0
  102. package/cjs/idx/idx-js/util.js +34 -0
  103. package/cjs/idx/idx-js/util.js.map +1 -0
  104. package/cjs/idx/idx-js/v1/actionParser.js +90 -0
  105. package/cjs/idx/idx-js/v1/actionParser.js.map +1 -0
  106. package/cjs/idx/idx-js/v1/generateIdxAction.js +117 -0
  107. package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -0
  108. package/cjs/idx/idx-js/v1/idxResponseParser.js +137 -0
  109. package/cjs/idx/idx-js/v1/idxResponseParser.js.map +1 -0
  110. package/cjs/idx/idx-js/v1/makeIdxState.js +64 -0
  111. package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -0
  112. package/cjs/idx/idx-js/v1/parsers.js +24 -0
  113. package/cjs/idx/idx-js/v1/parsers.js.map +1 -0
  114. package/cjs/idx/idx-js/v1/remediationParser.js +32 -0
  115. package/cjs/idx/idx-js/v1/remediationParser.js.map +1 -0
  116. package/cjs/idx/index.js +121 -109
  117. package/cjs/idx/index.js.map +1 -1
  118. package/cjs/idx/interact.js +53 -36
  119. package/cjs/idx/interact.js.map +1 -1
  120. package/cjs/idx/introspect.js +17 -19
  121. package/cjs/idx/introspect.js.map +1 -1
  122. package/cjs/idx/poll.js +13 -3
  123. package/cjs/idx/poll.js.map +1 -1
  124. package/cjs/idx/proceed.js +4 -7
  125. package/cjs/idx/proceed.js.map +1 -1
  126. package/cjs/idx/recoverPassword.js +1 -1
  127. package/cjs/idx/recoverPassword.js.map +1 -1
  128. package/cjs/idx/register.js +11 -16
  129. package/cjs/idx/register.js.map +1 -1
  130. package/cjs/idx/remediate.js +74 -27
  131. package/cjs/idx/remediate.js.map +1 -1
  132. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +12 -4
  133. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  134. package/cjs/idx/remediators/AuthenticatorVerificationData.js +52 -9
  135. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  136. package/cjs/idx/remediators/Base/AuthenticatorData.js +31 -13
  137. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  138. package/cjs/idx/remediators/Base/Remediator.js +67 -31
  139. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  140. package/cjs/idx/remediators/Base/SelectAuthenticator.js +46 -30
  141. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  142. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +16 -4
  143. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  144. package/cjs/idx/remediators/ChallengeAuthenticator.js +2 -2
  145. package/cjs/idx/remediators/ChallengeAuthenticator.js.map +1 -1
  146. package/cjs/idx/remediators/ChallengePoll.js +2 -2
  147. package/cjs/idx/remediators/EnrollAuthenticator.js +2 -2
  148. package/cjs/idx/remediators/EnrollAuthenticator.js.map +1 -1
  149. package/cjs/idx/remediators/EnrollPoll.js +18 -9
  150. package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
  151. package/cjs/idx/remediators/EnrollProfile.js +24 -9
  152. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  153. package/cjs/idx/remediators/EnrollmentChannelData.js +96 -0
  154. package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -0
  155. package/cjs/idx/remediators/Identify.js +5 -3
  156. package/cjs/idx/remediators/Identify.js.map +1 -1
  157. package/cjs/idx/remediators/ReEnrollAuthenticator.js +6 -3
  158. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  159. package/cjs/idx/remediators/RedirectIdp.js +2 -2
  160. package/cjs/idx/remediators/ResetAuthenticator.js +2 -2
  161. package/cjs/idx/remediators/ResetAuthenticator.js.map +1 -1
  162. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +7 -5
  163. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  164. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +2 -2
  165. package/cjs/idx/remediators/SelectAuthenticatorEnroll.js.map +1 -1
  166. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +72 -0
  167. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -0
  168. package/cjs/idx/remediators/SelectEnrollProfile.js +2 -2
  169. package/cjs/idx/remediators/SelectEnrollProfile.js.map +1 -1
  170. package/cjs/idx/remediators/SelectEnrollmentChannel.js +86 -0
  171. package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -0
  172. package/cjs/idx/remediators/Skip.js +5 -3
  173. package/cjs/idx/remediators/Skip.js.map +1 -1
  174. package/cjs/idx/remediators/index.js +57 -16
  175. package/cjs/idx/remediators/index.js.map +1 -1
  176. package/cjs/idx/remediators/util.js +18 -3
  177. package/cjs/idx/remediators/util.js.map +1 -1
  178. package/cjs/idx/run.js +145 -49
  179. package/cjs/idx/run.js.map +1 -1
  180. package/cjs/idx/startTransaction.js +4 -2
  181. package/cjs/idx/startTransaction.js.map +1 -1
  182. package/cjs/idx/transactionMeta.js +82 -69
  183. package/cjs/idx/transactionMeta.js.map +1 -1
  184. package/cjs/idx/types/idx-js.js.map +1 -1
  185. package/cjs/idx/types/index.js +59 -7
  186. package/cjs/idx/types/index.js.map +1 -1
  187. package/cjs/idx/unlockAccount.js +48 -0
  188. package/cjs/idx/unlockAccount.js.map +1 -0
  189. package/cjs/index.js +33 -13
  190. package/cjs/index.js.map +1 -1
  191. package/cjs/oidc/endpoints/authorize.js +10 -2
  192. package/cjs/oidc/endpoints/authorize.js.map +1 -1
  193. package/cjs/oidc/endpoints/index.js +5 -3
  194. package/cjs/oidc/endpoints/index.js.map +1 -1
  195. package/cjs/oidc/endpoints/token.js +16 -3
  196. package/cjs/oidc/endpoints/token.js.map +1 -1
  197. package/cjs/oidc/endpoints/well-known.js +7 -3
  198. package/cjs/oidc/endpoints/well-known.js.map +1 -1
  199. package/cjs/oidc/exchangeCodeForTokens.js +12 -4
  200. package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
  201. package/cjs/oidc/getToken.js +12 -6
  202. package/cjs/oidc/getToken.js.map +1 -1
  203. package/cjs/oidc/getUserInfo.js +7 -3
  204. package/cjs/oidc/getUserInfo.js.map +1 -1
  205. package/cjs/oidc/getWithPopup.js +8 -2
  206. package/cjs/oidc/getWithPopup.js.map +1 -1
  207. package/cjs/oidc/getWithRedirect.js +15 -38
  208. package/cjs/oidc/getWithRedirect.js.map +1 -1
  209. package/cjs/oidc/getWithoutPrompt.js +8 -2
  210. package/cjs/oidc/getWithoutPrompt.js.map +1 -1
  211. package/cjs/oidc/handleOAuthResponse.js +87 -87
  212. package/cjs/oidc/handleOAuthResponse.js.map +1 -1
  213. package/cjs/oidc/index.js +4 -2
  214. package/cjs/oidc/index.js.map +1 -1
  215. package/cjs/oidc/parseFromUrl.js +9 -3
  216. package/cjs/oidc/parseFromUrl.js.map +1 -1
  217. package/cjs/oidc/renewToken.js.map +1 -1
  218. package/cjs/oidc/renewTokens.js +6 -2
  219. package/cjs/oidc/renewTokens.js.map +1 -1
  220. package/cjs/oidc/renewTokensWithRefresh.js +5 -1
  221. package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
  222. package/cjs/oidc/revokeToken.js +34 -31
  223. package/cjs/oidc/revokeToken.js.map +1 -1
  224. package/cjs/oidc/util/browser.js +5 -1
  225. package/cjs/oidc/util/browser.js.map +1 -1
  226. package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
  227. package/cjs/oidc/util/errors.js.map +1 -1
  228. package/cjs/oidc/util/index.js +27 -11
  229. package/cjs/oidc/util/index.js.map +1 -1
  230. package/cjs/oidc/util/loginRedirect.js +10 -1
  231. package/cjs/oidc/util/loginRedirect.js.map +1 -1
  232. package/cjs/oidc/util/oauth.js +4 -2
  233. package/cjs/oidc/util/oauth.js.map +1 -1
  234. package/cjs/oidc/util/oauthMeta.js +36 -0
  235. package/cjs/oidc/util/oauthMeta.js.map +1 -0
  236. package/cjs/oidc/util/pkce.js +11 -3
  237. package/cjs/oidc/util/pkce.js.map +1 -1
  238. package/cjs/oidc/util/prepareTokenParams.js +62 -39
  239. package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
  240. package/cjs/oidc/util/validateClaims.js +3 -1
  241. package/cjs/oidc/util/validateClaims.js.map +1 -1
  242. package/cjs/oidc/verifyToken.js +13 -4
  243. package/cjs/oidc/verifyToken.js.map +1 -1
  244. package/cjs/options/browser.js +81 -0
  245. package/cjs/options/browser.js.map +1 -0
  246. package/cjs/options/index.js +94 -0
  247. package/cjs/options/index.js.map +1 -0
  248. package/cjs/options/node.js +46 -0
  249. package/cjs/options/node.js.map +1 -0
  250. package/cjs/server/serverStorage.js +9 -5
  251. package/cjs/server/serverStorage.js.map +1 -1
  252. package/cjs/services/AutoRenewService.js +94 -0
  253. package/cjs/services/AutoRenewService.js.map +1 -0
  254. package/cjs/services/SyncStorageService.js +93 -0
  255. package/cjs/services/SyncStorageService.js.map +1 -0
  256. package/cjs/services/index.js +30 -0
  257. package/cjs/services/index.js.map +1 -0
  258. package/cjs/tx/AuthTransaction.js +18 -9
  259. package/cjs/tx/AuthTransaction.js.map +1 -1
  260. package/cjs/tx/TransactionState.js +0 -17
  261. package/cjs/tx/TransactionState.js.map +1 -1
  262. package/cjs/tx/api.js +11 -6
  263. package/cjs/tx/api.js.map +1 -1
  264. package/cjs/tx/index.js +7 -5
  265. package/cjs/tx/index.js.map +1 -1
  266. package/cjs/tx/poll.js +6 -4
  267. package/cjs/tx/poll.js.map +1 -1
  268. package/cjs/tx/util.js +5 -1
  269. package/cjs/tx/util.js.map +1 -1
  270. package/cjs/types/Service.js +2 -0
  271. package/cjs/types/Service.js.map +1 -0
  272. package/cjs/types/Transaction.js +10 -2
  273. package/cjs/types/Transaction.js.map +1 -1
  274. package/cjs/types/index.js +29 -14
  275. package/cjs/types/index.js.map +1 -1
  276. package/cjs/util/index.js +7 -18
  277. package/cjs/util/index.js.map +1 -1
  278. package/cjs/util/misc.js +5 -1
  279. package/cjs/util/misc.js.map +1 -1
  280. package/cjs/util/object.js +16 -6
  281. package/cjs/util/object.js.map +1 -1
  282. package/cjs/util/sharedStorage.js +5 -1
  283. package/cjs/util/sharedStorage.js.map +1 -1
  284. package/cjs/util/url.js.map +1 -1
  285. package/dist/okta-auth-js.min.js +1 -1
  286. package/dist/okta-auth-js.min.js.LICENSE.txt +0 -20
  287. package/dist/okta-auth-js.min.js.map +1 -1
  288. package/dist/okta-auth-js.polyfill.js +1 -1
  289. package/dist/okta-auth-js.polyfill.js.map +1 -1
  290. package/dist/okta-auth-js.umd.js +1 -1
  291. package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -19
  292. package/dist/okta-auth-js.umd.js.map +1 -1
  293. package/esm/{index.js → esm.browser.js} +3283 -2698
  294. package/esm/esm.browser.js.map +1 -0
  295. package/esm/esm.node.mjs +9277 -0
  296. package/esm/esm.node.mjs.map +1 -0
  297. package/lib/AuthStateManager.d.ts +2 -5
  298. package/lib/OktaAuth.d.ts +14 -16
  299. package/lib/ServiceManager.d.ts +38 -0
  300. package/lib/StorageManager.d.ts +2 -2
  301. package/lib/TokenManager.d.ts +4 -5
  302. package/lib/TransactionManager.d.ts +4 -3
  303. package/lib/browser/fingerprint.d.ts +2 -3
  304. package/lib/builderUtil.d.ts +1 -2
  305. package/lib/crypto/base64.d.ts +2 -0
  306. package/lib/crypto/browser.d.ts +1 -1
  307. package/lib/crypto/webauthn.d.ts +25 -0
  308. package/lib/features.d.ts +1 -1
  309. package/lib/http/headers.d.ts +2 -2
  310. package/lib/http/request.d.ts +4 -4
  311. package/lib/idx/authenticate.d.ts +2 -2
  312. package/lib/idx/authenticator/Authenticator.d.ts +4 -5
  313. package/lib/idx/authenticator/OktaPassword.d.ts +7 -9
  314. package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +9 -8
  315. package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +7 -7
  316. package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +6 -2
  317. package/lib/idx/authenticator/WebauthnEnrollment.d.ts +16 -0
  318. package/lib/idx/authenticator/WebauthnVerification.d.ts +17 -0
  319. package/lib/idx/authenticator/getAuthenticator.d.ts +1 -1
  320. package/lib/idx/authenticator/index.d.ts +9 -0
  321. package/lib/idx/cancel.d.ts +2 -2
  322. package/lib/idx/emailVerify.d.ts +26 -0
  323. package/lib/{util/emailVerify.d.ts → idx/flow/AccountUnlockFlow.d.ts} +2 -6
  324. package/lib/idx/flow/FlowSpecification.d.ts +3 -2
  325. package/lib/idx/flow/index.d.ts +1 -0
  326. package/lib/idx/headers.d.ts +3 -2
  327. package/lib/idx/idx-js/client.d.ts +36 -0
  328. package/lib/idx/idx-js/index.d.ts +51 -0
  329. package/lib/idx/idx-js/interact.d.ts +25 -0
  330. package/lib/idx/idx-js/introspect.d.ts +20 -0
  331. package/lib/idx/idx-js/parsers.d.ts +15 -0
  332. package/lib/idx/idx-js/util.d.ts +12 -0
  333. package/lib/idx/idx-js/v1/actionParser.d.ts +16 -0
  334. package/lib/idx/idx-js/v1/generateIdxAction.d.ts +13 -0
  335. package/lib/idx/idx-js/v1/idxResponseParser.d.ts +20 -0
  336. package/lib/idx/idx-js/v1/makeIdxState.d.ts +13 -0
  337. package/lib/idx/idx-js/v1/parsers.d.ts +16 -0
  338. package/lib/idx/idx-js/v1/remediationParser.d.ts +12 -0
  339. package/lib/idx/index.d.ts +12 -10
  340. package/lib/idx/interact.d.ts +7 -13
  341. package/lib/idx/introspect.d.ts +4 -3
  342. package/lib/idx/poll.d.ts +2 -2
  343. package/lib/idx/proceed.d.ts +8 -5
  344. package/lib/idx/recoverPassword.d.ts +2 -2
  345. package/lib/idx/register.d.ts +2 -2
  346. package/lib/idx/remediate.d.ts +10 -4
  347. package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +3 -3
  348. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +5 -5
  349. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +10 -10
  350. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +10 -7
  351. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +8 -12
  352. package/lib/idx/remediators/EnrollProfile.d.ts +1 -1
  353. package/lib/idx/remediators/EnrollmentChannelData.d.ts +54 -0
  354. package/lib/idx/remediators/Identify.d.ts +2 -2
  355. package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -2
  356. package/lib/idx/remediators/RedirectIdp.d.ts +3 -3
  357. package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +38 -0
  358. package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +40 -0
  359. package/lib/idx/remediators/index.d.ts +3 -0
  360. package/lib/idx/remediators/util.d.ts +2 -2
  361. package/lib/idx/run.d.ts +5 -3
  362. package/lib/idx/startTransaction.d.ts +3 -2
  363. package/lib/idx/transactionMeta.d.ts +10 -31
  364. package/lib/idx/types/FlowIdentifier.d.ts +1 -1
  365. package/lib/idx/types/idx-js.d.ts +44 -1
  366. package/lib/idx/types/index.d.ts +36 -9
  367. package/lib/idx/unlockAccount.d.ts +15 -0
  368. package/lib/index.d.ts +1 -0
  369. package/lib/oidc/endpoints/well-known.d.ts +3 -3
  370. package/lib/oidc/exchangeCodeForTokens.d.ts +14 -2
  371. package/lib/oidc/getToken.d.ts +2 -2
  372. package/lib/oidc/getWithPopup.d.ts +2 -2
  373. package/lib/oidc/getWithRedirect.d.ts +2 -2
  374. package/lib/oidc/getWithoutPrompt.d.ts +2 -2
  375. package/lib/oidc/handleOAuthResponse.d.ts +2 -2
  376. package/lib/oidc/parseFromUrl.d.ts +1 -1
  377. package/lib/oidc/renewToken.d.ts +2 -2
  378. package/lib/oidc/renewTokens.d.ts +1 -1
  379. package/lib/oidc/renewTokensWithRefresh.d.ts +2 -2
  380. package/lib/oidc/revokeToken.d.ts +2 -2
  381. package/lib/oidc/util/browser.d.ts +3 -3
  382. package/lib/oidc/util/defaultTokenParams.d.ts +2 -2
  383. package/lib/oidc/util/errors.d.ts +2 -2
  384. package/lib/oidc/util/index.d.ts +1 -0
  385. package/lib/oidc/util/loginRedirect.d.ts +4 -4
  386. package/lib/oidc/util/oauth.d.ts +4 -11
  387. package/lib/oidc/util/oauthMeta.d.ts +2 -0
  388. package/lib/oidc/util/prepareTokenParams.d.ts +5 -2
  389. package/lib/oidc/util/validateClaims.d.ts +2 -2
  390. package/lib/oidc/verifyToken.d.ts +2 -2
  391. package/lib/options/browser.d.ts +16 -0
  392. package/lib/{options.d.ts → options/index.d.ts} +1 -1
  393. package/lib/options/node.d.ts +16 -0
  394. package/lib/server/serverStorage.d.ts +1 -1
  395. package/lib/services/AutoRenewService.d.ts +27 -0
  396. package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
  397. package/lib/services/index.d.ts +13 -0
  398. package/lib/tx/AuthTransaction.d.ts +2 -2
  399. package/lib/tx/TransactionState.d.ts +11 -1
  400. package/lib/tx/api.d.ts +6 -6
  401. package/lib/types/OktaAuthOptions.d.ts +11 -8
  402. package/lib/types/Service.d.ts +23 -0
  403. package/lib/types/Storage.d.ts +3 -3
  404. package/lib/types/Transaction.d.ts +10 -7
  405. package/lib/types/UserClaims.d.ts +3 -3
  406. package/lib/types/api.d.ts +49 -22
  407. package/lib/types/index.d.ts +1 -1
  408. package/lib/util/console.d.ts +1 -1
  409. package/lib/util/index.d.ts +0 -1
  410. package/lib/util/sharedStorage.d.ts +1 -1
  411. package/lib/util/types.d.ts +1 -1
  412. package/lib/util/url.d.ts +2 -2
  413. package/package.json +30 -13
  414. package/polyfill/index.js +1 -0
  415. package/cjs/options.js +0 -154
  416. package/cjs/options.js.map +0 -1
  417. package/cjs/services/TokenService.js +0 -108
  418. package/cjs/services/TokenService.js.map +0 -1
  419. package/cjs/util/emailVerify.js +0 -28
  420. package/cjs/util/emailVerify.js.map +0 -1
  421. package/esm/index.js.map +0 -1
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
 
5
+ exports.assertPKCESupport = assertPKCESupport;
6
+ exports.validateCodeChallengeMethod = validateCodeChallengeMethod;
7
+ exports.preparePKCE = preparePKCE;
5
8
  exports.prepareTokenParams = prepareTokenParams;
6
9
 
10
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
11
+
7
12
  var _wellKnown = require("../endpoints/well-known");
8
13
 
9
14
  var _errors = require("../../errors");
10
15
 
11
- var _util = require("../../util");
12
-
13
16
  var _defaultTokenParams = require("./defaultTokenParams");
14
17
 
15
18
  var _constants = require("../../constants");
16
19
 
17
20
  var _pkce = _interopRequireDefault(require("./pkce"));
18
21
 
22
+ /* eslint-disable complexity */
23
+
19
24
  /*!
20
25
  * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
21
26
  * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
@@ -28,18 +33,7 @@ var _pkce = _interopRequireDefault(require("./pkce"));
28
33
  * See the License for the specific language governing permissions and limitations under the License.
29
34
  *
30
35
  */
31
- // Prepares params for a call to /authorize or /token
32
- function prepareTokenParams(sdk, tokenParams) {
33
- // build params using defaults + options
34
- const defaults = (0, _defaultTokenParams.getDefaultTokenParams)(sdk);
35
- tokenParams = Object.assign({}, defaults, (0, _util.clone)(tokenParams));
36
-
37
- if (tokenParams.pkce === false) {
38
- // Implicit flow or authorization_code without PKCE
39
- return Promise.resolve(tokenParams);
40
- } // PKCE flow
41
-
42
-
36
+ function assertPKCESupport(sdk) {
43
37
  if (!sdk.features.isPKCESupported()) {
44
38
  var errorMessage = 'PKCE requires a modern browser with encryption support running in a secure context.';
45
39
 
@@ -53,35 +47,64 @@ function prepareTokenParams(sdk, tokenParams) {
53
47
  errorMessage += '\n"TextEncoder" is not defined. To use PKCE, you may need to include a polyfill/shim for this browser.';
54
48
  }
55
49
 
56
- return Promise.reject(new _errors.AuthSdkError(errorMessage));
57
- } // set default code challenge method, if none provided
50
+ throw new _errors.AuthSdkError(errorMessage);
51
+ }
52
+ }
58
53
 
54
+ async function validateCodeChallengeMethod(sdk, codeChallengeMethod) {
55
+ // set default code challenge method, if none provided
56
+ codeChallengeMethod = codeChallengeMethod || sdk.options.codeChallengeMethod || _constants.DEFAULT_CODE_CHALLENGE_METHOD; // validate against .well-known/openid-configuration
59
57
 
60
- if (!tokenParams.codeChallengeMethod) {
61
- tokenParams.codeChallengeMethod = _constants.DEFAULT_CODE_CHALLENGE_METHOD;
62
- } // responseType is forced
58
+ const wellKnownResponse = await (0, _wellKnown.getWellKnown)(sdk);
59
+ var methods = wellKnownResponse['code_challenge_methods_supported'] || [];
63
60
 
61
+ if ((0, _indexOf.default)(methods).call(methods, codeChallengeMethod) === -1) {
62
+ throw new _errors.AuthSdkError('Invalid code_challenge_method');
63
+ }
64
64
 
65
- tokenParams.responseType = 'code';
66
- return (0, _wellKnown.getWellKnown)(sdk, null).then(function (res) {
67
- var methods = res['code_challenge_methods_supported'] || [];
65
+ return codeChallengeMethod;
66
+ }
68
67
 
69
- if (methods.indexOf(tokenParams.codeChallengeMethod) === -1) {
70
- throw new _errors.AuthSdkError('Invalid code_challenge_method');
71
- }
72
- }).then(function () {
73
- if (!tokenParams.codeVerifier) {
74
- tokenParams.codeVerifier = _pkce.default.generateVerifier();
75
- }
68
+ async function preparePKCE(sdk, tokenParams) {
69
+ let {
70
+ codeVerifier,
71
+ codeChallenge,
72
+ codeChallengeMethod
73
+ } = tokenParams; // PKCE calculations can be avoided by passing a codeChallenge
74
+
75
+ codeChallenge = codeChallenge || sdk.options.codeChallenge;
76
+
77
+ if (!codeChallenge) {
78
+ assertPKCESupport(sdk);
79
+ codeVerifier = codeVerifier || _pkce.default.generateVerifier();
80
+ codeChallenge = await _pkce.default.computeChallenge(codeVerifier);
81
+ }
82
+
83
+ codeChallengeMethod = await validateCodeChallengeMethod(sdk, codeChallengeMethod); // Clone/copy the params. Set PKCE values
84
+
85
+ tokenParams = { ...tokenParams,
86
+ responseType: 'code',
87
+ // responseType is forced
88
+ codeVerifier,
89
+ codeChallenge,
90
+ codeChallengeMethod
91
+ };
92
+ return tokenParams;
93
+ } // Prepares params for a call to /authorize or /token
94
+
95
+
96
+ async function prepareTokenParams(sdk, tokenParams = {}) {
97
+ // build params using defaults + options
98
+ const defaults = (0, _defaultTokenParams.getDefaultTokenParams)(sdk);
99
+ tokenParams = { ...defaults,
100
+ ...tokenParams
101
+ };
102
+
103
+ if (tokenParams.pkce === false) {
104
+ // Implicit flow or authorization_code without PKCE
105
+ return tokenParams;
106
+ }
76
107
 
77
- return _pkce.default.computeChallenge(tokenParams.codeVerifier);
78
- }).then(function (codeChallenge) {
79
- // Clone/copy the params. Set codeChallenge
80
- var clonedParams = (0, _util.clone)(tokenParams) || {};
81
- Object.assign(clonedParams, tokenParams, {
82
- codeChallenge: codeChallenge
83
- });
84
- return clonedParams;
85
- });
108
+ return preparePKCE(sdk, tokenParams);
86
109
  }
87
110
  //# sourceMappingURL=prepareTokenParams.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../lib/oidc/util/prepareTokenParams.ts"],"names":["prepareTokenParams","sdk","tokenParams","defaults","Object","assign","pkce","Promise","resolve","features","isPKCESupported","errorMessage","isHTTPS","hasTextEncoder","reject","AuthSdkError","codeChallengeMethod","DEFAULT_CODE_CHALLENGE_METHOD","responseType","then","res","methods","indexOf","codeVerifier","generateVerifier","computeChallenge","codeChallenge","clonedParams"],"mappings":";;;;;;AAYA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AASA;AACO,SAASA,kBAAT,CAA4BC,GAA5B,EAA2CC,WAA3C,EAA4F;AACjG;AACA,QAAMC,QAAQ,GAAG,+CAAsBF,GAAtB,CAAjB;AACAC,EAAAA,WAAW,GAAGE,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBF,QAAlB,EAA4B,iBAAMD,WAAN,CAA5B,CAAd;;AAEA,MAAIA,WAAW,CAACI,IAAZ,KAAqB,KAAzB,EAAgC;AAC9B;AACA,WAAOC,OAAO,CAACC,OAAR,CAAgBN,WAAhB,CAAP;AACD,GARgG,CAUjG;;;AACA,MAAI,CAACD,GAAG,CAACQ,QAAJ,CAAaC,eAAb,EAAL,EAAqC;AACnC,QAAIC,YAAY,GAAG,qFAAnB;;AACA,QAAI,CAACV,GAAG,CAACQ,QAAJ,CAAaG,OAAb,EAAL,EAA6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(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 { getWellKnown } from '../endpoints/well-known';\nimport { AuthSdkError } from '../../errors';\nimport { OktaAuth, TokenParams } from '../../types';\nimport { clone } from '../../util';\nimport { getDefaultTokenParams } from './defaultTokenParams';\nimport { DEFAULT_CODE_CHALLENGE_METHOD } from '../../constants';\nimport pkce from './pkce';\n\n// Prepares params for a call to /authorize or /token\nexport function prepareTokenParams(sdk: OktaAuth, tokenParams?: TokenParams): Promise<TokenParams> {\n // build params using defaults + options\n const defaults = getDefaultTokenParams(sdk);\n tokenParams = Object.assign({}, defaults, clone(tokenParams));\n\n if (tokenParams.pkce === false) {\n // Implicit flow or authorization_code without PKCE\n return Promise.resolve(tokenParams);\n }\n\n // PKCE flow\n if (!sdk.features.isPKCESupported()) {\n var errorMessage = 'PKCE requires a modern browser with encryption support running in a secure context.';\n if (!sdk.features.isHTTPS()) {\n // eslint-disable-next-line max-len\n errorMessage += '\\nThe current page is not being served with HTTPS protocol. PKCE requires secure HTTPS protocol.';\n }\n if (!sdk.features.hasTextEncoder()) {\n // eslint-disable-next-line max-len\n errorMessage += '\\n\"TextEncoder\" is not defined. To use PKCE, you may need to include a polyfill/shim for this browser.';\n }\n return Promise.reject(new AuthSdkError(errorMessage));\n }\n\n // set default code challenge method, if none provided\n if (!tokenParams.codeChallengeMethod) {\n tokenParams.codeChallengeMethod = DEFAULT_CODE_CHALLENGE_METHOD;\n }\n\n // responseType is forced\n tokenParams.responseType = 'code';\n\n return getWellKnown(sdk, null)\n .then(function (res) {\n var methods = res['code_challenge_methods_supported'] || [];\n if (methods.indexOf(tokenParams.codeChallengeMethod) === -1) {\n throw new AuthSdkError('Invalid code_challenge_method');\n }\n })\n .then(function () {\n if (!tokenParams.codeVerifier) {\n tokenParams.codeVerifier = pkce.generateVerifier();\n }\n return pkce.computeChallenge(tokenParams.codeVerifier);\n })\n .then(function (codeChallenge) {\n // Clone/copy the params. Set codeChallenge\n var clonedParams = clone(tokenParams) || {};\n Object.assign(clonedParams, tokenParams, {\n codeChallenge: codeChallenge,\n });\n return clonedParams;\n });\n}"],"file":"prepareTokenParams.js"}
1
+ {"version":3,"sources":["../../../../lib/oidc/util/prepareTokenParams.ts"],"names":["assertPKCESupport","sdk","features","isPKCESupported","errorMessage","isHTTPS","hasTextEncoder","AuthSdkError","validateCodeChallengeMethod","codeChallengeMethod","options","DEFAULT_CODE_CHALLENGE_METHOD","wellKnownResponse","methods","preparePKCE","tokenParams","codeVerifier","codeChallenge","PKCE","generateVerifier","computeChallenge","responseType","prepareTokenParams","defaults","pkce"],"mappings":";;;;;;;;;;;AAaA;;AACA;;AAEA;;AACA;;AACA;;AAlBA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQO,SAASA,iBAAT,CAA2BC,GAA3B,EAAmD;AACxD,MAAI,CAACA,GAAG,CAACC,QAAJ,CAAaC,eAAb,EAAL,EAAqC;AACnC,QAAIC,YAAY,GAAG,qFAAnB;;AACA,QAAI,CAACH,GAAG,CAACC,QAAJ,CAAaG,OAAb,EAAL,EAA6B;AAC3B;AACAD,MAAAA,YAAY,IAAI,kGAAhB;AACD;;AACD,QAAI,CAACH,GAAG,CAACC,QAAJ,CAAaI,cAAb,EAAL,EAAoC;AAClC;AACAF,MAAAA,YAAY,IAAI,wGAAhB;AACD;;AACD,UAAM,IAAIG,oBAAJ,CAAiBH,YAAjB,CAAN;AACD;AACF;;AAEM,eAAeI,2BAAf,CAA2CP,GAA3C,EAAmEQ,mBAAnE,EAAiG;AACtG;AACAA,EAAAA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;AACAc,EAAAA,WAAW,GAAG,EAAE,GAAGQ,QAAL;AAAe,OAAGR;AAAlB,GAAd;;AAEA,MAAIA,WAAW,CAACS,IAAZ,KAAqB,KAAzB,EAAgC;AAC9B;AACA,WAAOT,WAAP;AACD;;AAED,SAAOD,WAAW,CAACb,GAAD,EAAMc,WAAN,CAAlB;AACD","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 { getWellKnown } from '../endpoints/well-known';\nimport { AuthSdkError } from '../../errors';\nimport { OktaAuthInterface, TokenParams } from '../../types';\nimport { getDefaultTokenParams } from './defaultTokenParams';\nimport { DEFAULT_CODE_CHALLENGE_METHOD } from '../../constants';\nimport PKCE from './pkce';\n\nexport function assertPKCESupport(sdk: OktaAuthInterface) {\n if (!sdk.features.isPKCESupported()) {\n var errorMessage = 'PKCE requires a modern browser with encryption support running in a secure context.';\n if (!sdk.features.isHTTPS()) {\n // eslint-disable-next-line max-len\n errorMessage += '\\nThe current page is not being served with HTTPS protocol. PKCE requires secure HTTPS protocol.';\n }\n if (!sdk.features.hasTextEncoder()) {\n // eslint-disable-next-line max-len\n errorMessage += '\\n\"TextEncoder\" is not defined. To use PKCE, you may need to include a polyfill/shim for this browser.';\n }\n throw new AuthSdkError(errorMessage);\n }\n}\n\nexport async function validateCodeChallengeMethod(sdk: OktaAuthInterface, codeChallengeMethod?: string) {\n // set default code challenge method, if none provided\n codeChallengeMethod = codeChallengeMethod || sdk.options.codeChallengeMethod || DEFAULT_CODE_CHALLENGE_METHOD;\n\n // validate against .well-known/openid-configuration\n const wellKnownResponse = await getWellKnown(sdk);\n var methods = wellKnownResponse['code_challenge_methods_supported'] || [];\n if (methods.indexOf(codeChallengeMethod) === -1) {\n throw new AuthSdkError('Invalid code_challenge_method');\n }\n return codeChallengeMethod;\n}\n\nexport async function preparePKCE(\n sdk: OktaAuthInterface, \n tokenParams: TokenParams\n): Promise<TokenParams> {\n let {\n codeVerifier,\n codeChallenge,\n codeChallengeMethod\n } = tokenParams;\n\n // PKCE calculations can be avoided by passing a codeChallenge\n codeChallenge = codeChallenge || sdk.options.codeChallenge;\n if (!codeChallenge) {\n assertPKCESupport(sdk);\n codeVerifier = codeVerifier || PKCE.generateVerifier();\n codeChallenge = await PKCE.computeChallenge(codeVerifier);\n }\n codeChallengeMethod = await validateCodeChallengeMethod(sdk, codeChallengeMethod);\n\n // Clone/copy the params. Set PKCE values\n tokenParams = {\n ...tokenParams,\n responseType: 'code', // responseType is forced\n codeVerifier,\n codeChallenge,\n codeChallengeMethod\n };\n\n return tokenParams;\n}\n\n// Prepares params for a call to /authorize or /token\nexport async function prepareTokenParams(\n sdk: OktaAuthInterface,\n tokenParams: TokenParams = {}\n): Promise<TokenParams> {\n // build params using defaults + options\n const defaults = getDefaultTokenParams(sdk);\n tokenParams = { ...defaults, ...tokenParams };\n\n if (tokenParams.pkce === false) {\n // Implicit flow or authorization_code without PKCE\n return tokenParams;\n }\n\n return preparePKCE(sdk, tokenParams);\n}"],"file":"prepareTokenParams.js"}
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
4
 
5
5
  exports.validateClaims = validateClaims;
6
6
 
7
7
  var _AuthSdkError = _interopRequireDefault(require("../../errors/AuthSdkError"));
8
8
 
9
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
10
+
9
11
  /*!
10
12
  * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
11
13
  * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../lib/oidc/util/validateClaims.ts"],"names":["validateClaims","sdk","claims","validationParams","aud","clientId","iss","issuer","nonce","AuthSdkError","now","Math","floor","Date","iat","exp","options","ignoreLifetime","maxClockSkew"],"mappings":";;;;;;AAcA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAKO,SAASA,cAAT,CAAwBC,GAAxB,EAAuCC,MAAvC,EAA2DC,gBAA3D,EAAgG;AACrG,MAAIC,GAAG,GAAGD,gBAAgB,CAACE,QAA3B;AACA,MAAIC,GAAG,GAAGH,gBAAgB,CAACI,MAA3B;AACA,MAAIC,KAAK,GAAGL,gBAAgB,CAACK,KAA7B;;AAEA,MAAI,CAACN,MAAD,IAAW,CAACI,GAAZ,IAAmB,CAACF,GAAxB,EAA6B;AAC3B,UAAM,IAAIK,qBAAJ,CAAiB,kDAAjB,CAAN;AACD;;AAED,MAAID,KAAK,IAAIN,MAAM,CAACM,KAAP,KAAiBA,KAA9B,EAAqC;AACnC,UAAM,IAAIC,qBAAJ,CAAiB,wDAAjB,CAAN;AACD;;AAED,MAAIC,GAAG,GAAGC,IAAI,CAACC,KAAL,CAAWC,IAAI,CAACH,GAAL,KAAW,IAAtB,CAAV;;AAEA,MAAIR,MAAM,CAACI,GAAP,KAAeA,GAAnB,EAAwB;AACtB,UAAM,IAAIG,qBAAJ,CAAiB,iBAAiBP,MAAM,CAACI,GAAxB,GAA8B,IAA9B,GACrB,kBADqB,GACAA,GADA,GACM,GADvB,CAAN;AAED;;AAED,MAAIJ,MAAM,CAACE,GAAP,KAAeA,GAAnB,EAAwB;AACtB,UAAM,IAAIK,qBAAJ,CAAiB,mBAAmBP,MAAM,CAACE,GAA1B,GAAgC,IAAhC,GACrB,kBADqB,GACAA,GADA,GACM,GADvB,CAAN;AAED;;AAED,MAAIF,MAAM,CAACY,GAAP,GAAaZ,MAAM,CAACa,GAAxB,EAA6B;AAC3B,UAAM,IAAIN,qBAAJ,CAAiB,sCAAjB,CAAN;AACD;;AAED,MAAI,CAACR,GAAG,CAACe,OAAJ,CAAYC,cAAjB,EAAiC;AAC/B,QAAKP,GAAG,GAAGT,GAAG,CAACe,OAAJ,CAAYE,YAAnB,GAAmChB,MAAM,CAACa,GAA9C,EAAmD;AACjD,YAAM,IAAIN,qBAAJ,CAAiB,wCAAjB,CAAN;AACD;;AAED,QAAIP,MAAM,CAACY,GAAP,GAAcJ,GAAG,GAAGT,GAAG,CAACe,OAAJ,CAAYE,YAApC,EAAmD;AACjD,YAAM,IAAIT,qBAAJ,CAAiB,kCAAjB,CAAN;AACD;AACF;AACF","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/* eslint-disable complexity, max-statements */\n\nimport AuthSdkError from '../../errors/AuthSdkError';\nimport { OktaAuth, TokenVerifyParams, UserClaims } from '../../types';\n\nexport function validateClaims(sdk: OktaAuth, claims: UserClaims, validationParams: TokenVerifyParams) {\n var aud = validationParams.clientId;\n var iss = validationParams.issuer;\n var nonce = validationParams.nonce;\n\n if (!claims || !iss || !aud) {\n throw new AuthSdkError('The jwt, iss, and aud arguments are all required');\n }\n\n if (nonce && claims.nonce !== nonce) {\n throw new AuthSdkError('OAuth flow response nonce doesn\\'t match request nonce');\n }\n\n var now = Math.floor(Date.now()/1000);\n\n if (claims.iss !== iss) {\n throw new AuthSdkError('The issuer [' + claims.iss + '] ' +\n 'does not match [' + iss + ']');\n }\n\n if (claims.aud !== aud) {\n throw new AuthSdkError('The audience [' + claims.aud + '] ' +\n 'does not match [' + aud + ']');\n }\n\n if (claims.iat > claims.exp) {\n throw new AuthSdkError('The JWT expired before it was issued');\n }\n\n if (!sdk.options.ignoreLifetime) {\n if ((now - sdk.options.maxClockSkew) > claims.exp) {\n throw new AuthSdkError('The JWT expired and is no longer valid');\n }\n\n if (claims.iat > (now + sdk.options.maxClockSkew)) {\n throw new AuthSdkError('The JWT was issued in the future');\n }\n }\n}\n"],"file":"validateClaims.js"}
1
+ {"version":3,"sources":["../../../../lib/oidc/util/validateClaims.ts"],"names":["validateClaims","sdk","claims","validationParams","aud","clientId","iss","issuer","nonce","AuthSdkError","now","Math","floor","Date","iat","exp","options","ignoreLifetime","maxClockSkew"],"mappings":";;;;;;AAeA;;AAfA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAKO,SAASA,cAAT,CAAwBC,GAAxB,EAAgDC,MAAhD,EAAoEC,gBAApE,EAAyG;AAC9G,MAAIC,GAAG,GAAGD,gBAAgB,CAACE,QAA3B;AACA,MAAIC,GAAG,GAAGH,gBAAgB,CAACI,MAA3B;AACA,MAAIC,KAAK,GAAGL,gBAAgB,CAACK,KAA7B;;AAEA,MAAI,CAACN,MAAD,IAAW,CAACI,GAAZ,IAAmB,CAACF,GAAxB,EAA6B;AAC3B,UAAM,IAAIK,qBAAJ,CAAiB,kDAAjB,CAAN;AACD;;AAED,MAAID,KAAK,IAAIN,MAAM,CAACM,KAAP,KAAiBA,KAA9B,EAAqC;AACnC,UAAM,IAAIC,qBAAJ,CAAiB,wDAAjB,CAAN;AACD;;AAED,MAAIC,GAAG,GAAGC,IAAI,CAACC,KAAL,CAAWC,IAAI,CAACH,GAAL,KAAW,IAAtB,CAAV;;AAEA,MAAIR,MAAM,CAACI,GAAP,KAAeA,GAAnB,EAAwB;AACtB,UAAM,IAAIG,qBAAJ,CAAiB,iBAAiBP,MAAM,CAACI,GAAxB,GAA8B,IAA9B,GACrB,kBADqB,GACAA,GADA,GACM,GADvB,CAAN;AAED;;AAED,MAAIJ,MAAM,CAACE,GAAP,KAAeA,GAAnB,EAAwB;AACtB,UAAM,IAAIK,qBAAJ,CAAiB,mBAAmBP,MAAM,CAACE,GAA1B,GAAgC,IAAhC,GACrB,kBADqB,GACAA,GADA,GACM,GADvB,CAAN;AAED;;AAED,MAAIF,MAAM,CAACY,GAAP,GAAcZ,MAAM,CAACa,GAAzB,EAA+B;AAC7B,UAAM,IAAIN,qBAAJ,CAAiB,sCAAjB,CAAN;AACD;;AAED,MAAI,CAACR,GAAG,CAACe,OAAJ,CAAYC,cAAjB,EAAiC;AAC/B,QAAKP,GAAG,GAAGT,GAAG,CAACe,OAAJ,CAAYE,YAAnB,GAAoChB,MAAM,CAACa,GAA/C,EAAqD;AACnD,YAAM,IAAIN,qBAAJ,CAAiB,wCAAjB,CAAN;AACD;;AAED,QAAIP,MAAM,CAACY,GAAP,GAAeJ,GAAG,GAAGT,GAAG,CAACe,OAAJ,CAAYE,YAArC,EAAqD;AACnD,YAAM,IAAIT,qBAAJ,CAAiB,kCAAjB,CAAN;AACD;AACF;AACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\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 */\n/* eslint-disable complexity, max-statements */\n\nimport AuthSdkError from '../../errors/AuthSdkError';\nimport { OktaAuthInterface, TokenVerifyParams, UserClaims } from '../../types';\n\nexport function validateClaims(sdk: OktaAuthInterface, claims: UserClaims, validationParams: TokenVerifyParams) {\n var aud = validationParams.clientId;\n var iss = validationParams.issuer;\n var nonce = validationParams.nonce;\n\n if (!claims || !iss || !aud) {\n throw new AuthSdkError('The jwt, iss, and aud arguments are all required');\n }\n\n if (nonce && claims.nonce !== nonce) {\n throw new AuthSdkError('OAuth flow response nonce doesn\\'t match request nonce');\n }\n\n var now = Math.floor(Date.now()/1000);\n\n if (claims.iss !== iss) {\n throw new AuthSdkError('The issuer [' + claims.iss + '] ' +\n 'does not match [' + iss + ']');\n }\n\n if (claims.aud !== aud) {\n throw new AuthSdkError('The audience [' + claims.aud + '] ' +\n 'does not match [' + aud + ']');\n }\n\n if (claims.iat! > claims.exp!) {\n throw new AuthSdkError('The JWT expired before it was issued');\n }\n\n if (!sdk.options.ignoreLifetime) {\n if ((now - sdk.options.maxClockSkew!) > claims.exp!) {\n throw new AuthSdkError('The JWT expired and is no longer valid');\n }\n\n if (claims.iat! > (now + sdk.options.maxClockSkew!)) {\n throw new AuthSdkError('The JWT was issued in the future');\n }\n }\n}\n"],"file":"validateClaims.js"}
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
5
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
6
+
7
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
8
+
3
9
  exports.verifyToken = verifyToken;
4
10
 
11
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
12
+
5
13
  var _wellKnown = require("./endpoints/well-known");
6
14
 
7
15
  var _util = require("./util");
@@ -12,9 +20,9 @@ var _decodeToken = require("./decodeToken");
12
20
 
13
21
  var sdkCrypto = _interopRequireWildcard(require("../crypto"));
14
22
 
15
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
24
 
17
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
26
 
19
27
  /* eslint-disable max-len */
20
28
 
@@ -46,7 +54,7 @@ async function verifyToken(sdk, token, validationParams) {
46
54
  const {
47
55
  issuer
48
56
  } = await (0, _wellKnown.getWellKnown)(sdk, configuredIssuer);
49
- var validationOptions = Object.assign({
57
+ var validationOptions = (0, _assign.default)({
50
58
  // base options, can be overridden by params
51
59
  clientId: sdk.options.clientId,
52
60
  ignoreSignature: sdk.options.ignoreSignature
@@ -60,7 +68,8 @@ async function verifyToken(sdk, token, validationParams) {
60
68
 
61
69
  if (validationOptions.ignoreSignature == true || !sdk.features.isTokenVerifySupported()) {
62
70
  return token;
63
- }
71
+ } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
72
+
64
73
 
65
74
  const key = await (0, _wellKnown.getKey)(sdk, token.issuer, jwt.header.kid);
66
75
  const valid = await sdkCrypto.verifyToken(token.idToken, key);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/oidc/verifyToken.ts"],"names":["verifyToken","sdk","token","validationParams","idToken","AuthSdkError","jwt","configuredIssuer","issuer","options","validationOptions","Object","assign","clientId","ignoreSignature","payload","features","isTokenVerifySupported","key","header","kid","valid","sdkCrypto","accessToken","claims","at_hash","hash","getOidcHash"],"mappings":";;;;AAcA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAnBA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACO,eAAeA,WAAf,CAA2BC,GAA3B,EAA0CC,KAA1C,EAA0DC,gBAA1D,EAAiH;AACtH,MAAI,CAACD,KAAD,IAAU,CAACA,KAAK,CAACE,OAArB,EAA8B;AAC5B,UAAM,IAAIC,oBAAJ,CAAiB,+BAAjB,CAAN;AACD,GAHqH,CAKtH;;;AACA,MAAIC,GAAG,GAAG,8BAAYJ,KAAK,CAACE,OAAlB,CAAV,CANsH,CAQtH;AACA;;AACA,QAAMG,gBAAgB,GAAG,CAAAJ,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEK,MAAlB,KAA4BP,GAAG,CAACQ,OAAJ,CA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AACD","sourcesContent":["/* eslint-disable max-len */\n/* 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 { getWellKnown, getKey } from './endpoints/well-known';\nimport { validateClaims } from './util';\nimport { AuthSdkError } from '../errors';\nimport { IDToken, OktaAuth, TokenVerifyParams } from '../types';\nimport { decodeToken } from './decodeToken';\nimport * as sdkCrypto from '../crypto';\n\n// Verify the id token\nexport async function verifyToken(sdk: OktaAuth, token: IDToken, validationParams: TokenVerifyParams): Promise<IDToken> {\n if (!token || !token.idToken) {\n throw new AuthSdkError('Only idTokens may be verified');\n }\n\n // Decode the Jwt object (may throw)\n var jwt = decodeToken(token.idToken);\n\n // The configured issuer may point to a frontend proxy.\n // Get the \"real\" issuer from .well-known/openid-configuration\n const configuredIssuer = validationParams?.issuer || sdk.options.issuer;\n const { issuer } = await getWellKnown(sdk, configuredIssuer);\n\n var validationOptions: TokenVerifyParams = Object.assign({\n // base options, can be overridden by params\n clientId: sdk.options.clientId,\n ignoreSignature: sdk.options.ignoreSignature\n }, validationParams, {\n // final options, cannot be overridden\n issuer\n });\n\n // Standard claim validation (may throw)\n validateClaims(sdk, jwt.payload, validationOptions);\n\n // If the browser doesn't support native crypto or we choose not\n // to verify the signature, bail early\n if (validationOptions.ignoreSignature == true || !sdk.features.isTokenVerifySupported()) {\n return token;\n }\n\n const key = await getKey(sdk, token.issuer, jwt.header.kid);\n const valid = await sdkCrypto.verifyToken(token.idToken, key);\n if (!valid) {\n throw new AuthSdkError('The token signature is not valid');\n }\n if (validationParams && validationParams.accessToken && token.claims.at_hash) {\n const hash = await sdkCrypto.getOidcHash(validationParams.accessToken);\n if (hash !== token.claims.at_hash) {\n throw new AuthSdkError('Token hash verification failed');\n }\n }\n return token;\n}\n"],"file":"verifyToken.js"}
1
+ {"version":3,"sources":["../../../lib/oidc/verifyToken.ts"],"names":["verifyToken","sdk","token","validationParams","idToken","AuthSdkError","jwt","configuredIssuer","issuer","options","validationOptions","clientId","ignoreSignature","payload","features","isTokenVerifySupported","key","header","kid","valid","sdkCrypto","accessToken","claims","at_hash","hash","getOidcHash"],"mappings":";;;;;;;;;;;;AAcA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAnBA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA;AACO,eAAeA,WAAf,CAA2BC,GAA3B,EAAmDC,KAAnD,EAAmEC,gBAAnE,EAA0H;AAC/H,MAAI,CAACD,KAAD,IAAU,CAACA,KAAK,CAACE,OAArB,EAA8B;AAC5B,UAAM,IAAIC,oBAAJ,CAAiB,+BAAjB,CAAN;AACD,GAH8H,CAK/H;;;AACA,MAAIC,GAAG,GAAG,8BAAYJ,KAAK,CAACE,OAAlB,CAAV,CAN+H,CAQ/H;AACA;;AACA,QAAMG,gBAAgB,GAAG,CAAAJ,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEK,MAAlB,KAA4BP,GAAG,CAACQ,OAAJ,CAAYD,MAAjE;AACA,QAAM;AAAEA,IAAAA;AAAF,MAAa,MAAM,6BAAaP,GAAb,EAAkBM,gBAAlB,CAAzB;AAEA,MAAIG,iBAAoC,GAAG,qBAAc;AACvD;AACAC,IAAAA,QAAQ,EAAEV,GAAG,CAACQ,OAAJ,CAAYE,QAFiC;AAGvDC,IAAAA,eAAe,EAAEX,GAAG,CAACQ,OAAJ,CAAYG;AAH0B,GAAd,EAIxCT,gBAJwC,EAItB;AACnB;AACAK,IAAAA;AAFmB,GAJsB,CAA3C,CAb+H,CAsB/H;;AACA,4BAAeP,GAAf,EAAoBK,GAAG,CAACO,OAAxB,EAAiCH,iBAAjC,EAvB+H,CAyB/H;AACA;;AACA,MAAIA,iBAAiB,CAACE,eAAlB,IAAqC,IAArC,IAA6C,CAACX,GAAG,CAACa,QAAJ,CAAaC,sBAAb,EAAlD,EAAyF;AACvF,WAAOb,KAAP;AACD,GA7B8H,CA+B/H;;;AACA,QAAMc,GAAG,GAAG,MAAM,uBAAOf,GAAP,EAAYC,KAAK,CAACM,MAAlB,EAA0BF,GAAG,CAACW,MAAJ,CAAWC,GAArC,CAAlB;AACA,QAAMC,KAAK,GAAG,MAAMC,SAAS,CAACpB,WAAV,CAAsBE,KAAK,CAACE,OAA5B,EAAqCY,GAArC,CAApB;;AACA,MAAI,CAACG,KAAL,EAAY;AACV,UAAM,IAAId,oBAAJ,CAAiB,kCAAjB,CAAN;AACD;;AACD,MAAIF,gBAAgB,IAAIA,gBAAgB,CAACkB,WAArC,IAAoDnB,KAAK,CAACoB,MAAN,CAAaC,OAArE,EAA8E;AAC5E,UAAMC,IAAI,GAAG,MAAMJ,SAAS,CAACK,WAAV,CAAsBtB,gBAAgB,CAACkB,WAAvC,CAAnB;;AACA,QAAIG,IAAI,KAAKtB,KAAK,CAACoB,MAAN,CAAaC,OAA1B,EAAmC;AACjC,YAAM,IAAIlB,oBAAJ,CAAiB,gCAAjB,CAAN;AACD;AACF;;AACD,SAAOH,KAAP;AACD","sourcesContent":["/* eslint-disable max-len */\n/* 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 { getWellKnown, getKey } from './endpoints/well-known';\nimport { validateClaims } from './util';\nimport { AuthSdkError } from '../errors';\nimport { IDToken, OktaAuthInterface, TokenVerifyParams } from '../types';\nimport { decodeToken } from './decodeToken';\nimport * as sdkCrypto from '../crypto';\n\n// Verify the id token\nexport async function verifyToken(sdk: OktaAuthInterface, token: IDToken, validationParams: TokenVerifyParams): Promise<IDToken> {\n if (!token || !token.idToken) {\n throw new AuthSdkError('Only idTokens may be verified');\n }\n\n // Decode the Jwt object (may throw)\n var jwt = decodeToken(token.idToken);\n\n // The configured issuer may point to a frontend proxy.\n // Get the \"real\" issuer from .well-known/openid-configuration\n const configuredIssuer = validationParams?.issuer || sdk.options.issuer;\n const { issuer } = await getWellKnown(sdk, configuredIssuer);\n\n var validationOptions: TokenVerifyParams = Object.assign({\n // base options, can be overridden by params\n clientId: sdk.options.clientId,\n ignoreSignature: sdk.options.ignoreSignature\n }, validationParams, {\n // final options, cannot be overridden\n issuer\n });\n\n // Standard claim validation (may throw)\n validateClaims(sdk, jwt.payload, validationOptions);\n\n // If the browser doesn't support native crypto or we choose not\n // to verify the signature, bail early\n if (validationOptions.ignoreSignature == true || !sdk.features.isTokenVerifySupported()) {\n return token;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const key = await getKey(sdk, token.issuer, jwt.header.kid!);\n const valid = await sdkCrypto.verifyToken(token.idToken, key);\n if (!valid) {\n throw new AuthSdkError('The token signature is not valid');\n }\n if (validationParams && validationParams.accessToken && token.claims.at_hash) {\n const hash = await sdkCrypto.getOidcHash(validationParams.accessToken);\n if (hash !== token.claims.at_hash) {\n throw new AuthSdkError('Token hash verification failed');\n }\n }\n return token;\n}\n"],"file":"verifyToken.js"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ exports.getCookieSettings = getCookieSettings;
6
+ Object.defineProperty(exports, "storage", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _browserStorage.default;
10
+ }
11
+ });
12
+ exports.enableSharedStorage = exports.STORAGE_MANAGER_OPTIONS = void 0;
13
+
14
+ var _util = require("../util");
15
+
16
+ var _browserStorage = _interopRequireDefault(require("../browser/browserStorage"));
17
+
18
+ /*!
19
+ * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
20
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
21
+ *
22
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ *
27
+ * See the License for the specific language governing permissions and limitations under the License.
28
+ */
29
+
30
+ /* eslint-disable complexity */
31
+ const STORAGE_MANAGER_OPTIONS = {
32
+ token: {
33
+ storageTypes: ['localStorage', 'sessionStorage', 'cookie']
34
+ },
35
+ cache: {
36
+ storageTypes: ['localStorage', 'sessionStorage', 'cookie']
37
+ },
38
+ transaction: {
39
+ storageTypes: ['sessionStorage', 'localStorage', 'cookie']
40
+ },
41
+ 'shared-transaction': {
42
+ storageTypes: ['localStorage']
43
+ },
44
+ 'original-uri': {
45
+ storageTypes: ['localStorage']
46
+ }
47
+ };
48
+ exports.STORAGE_MANAGER_OPTIONS = STORAGE_MANAGER_OPTIONS;
49
+ const enableSharedStorage = true;
50
+ exports.enableSharedStorage = enableSharedStorage;
51
+
52
+ function getCookieSettings(args = {}, isHTTPS) {
53
+ // Secure cookies will be automatically used on a HTTPS connection
54
+ // Non-secure cookies will be automatically used on a HTTP connection
55
+ // secure option can override the automatic behavior
56
+ var cookieSettings = args.cookies || {};
57
+
58
+ if (typeof cookieSettings.secure === 'undefined') {
59
+ cookieSettings.secure = isHTTPS;
60
+ }
61
+
62
+ if (typeof cookieSettings.sameSite === 'undefined') {
63
+ cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';
64
+ } // If secure=true, but the connection is not HTTPS, set secure=false.
65
+
66
+
67
+ if (cookieSettings.secure && !isHTTPS) {
68
+ // eslint-disable-next-line no-console
69
+ (0, _util.warn)('The current page is not being served with the HTTPS protocol.\n' + 'For security reasons, we strongly recommend using HTTPS.\n' + 'If you cannot use HTTPS, set "cookies.secure" option to false.');
70
+ cookieSettings.secure = false;
71
+ } // Chrome >= 80 will block cookies with SameSite=None unless they are also Secure
72
+ // If sameSite=none, but the connection is not HTTPS, set sameSite=lax.
73
+
74
+
75
+ if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {
76
+ cookieSettings.sameSite = 'lax';
77
+ }
78
+
79
+ return cookieSettings;
80
+ }
81
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../lib/options/browser.ts"],"names":["STORAGE_MANAGER_OPTIONS","token","storageTypes","cache","transaction","enableSharedStorage","getCookieSettings","args","isHTTPS","cookieSettings","cookies","secure","sameSite"],"mappings":";;;;;;;;;;;;;AAcA;;AAEA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAMO,MAAMA,uBAA8C,GAAG;AAC5DC,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GADqD;AAQ5DC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GARqD;AAe5DE,EAAAA,WAAW,EAAE;AACXF,IAAAA,YAAY,EAAE,CACZ,gBADY,EAEZ,cAFY,EAGZ,QAHY;AADH,GAf+C;AAsB5D,wBAAsB;AACpBA,IAAAA,YAAY,EAAE,CACZ,cADY;AADM,GAtBsC;AA2B5D,kBAAgB;AACdA,IAAAA,YAAY,EAAE,CACZ,cADY;AADA;AA3B4C,CAAvD;;AAkCA,MAAMG,mBAAmB,GAAG,IAA5B;;;AAEA,SAASC,iBAAT,CAA2BC,IAAqB,GAAG,EAAnD,EAAuDC,OAAvD,EAAyE;AAC9E;AACA;AACA;AACA,MAAIC,cAAc,GAAGF,IAAI,CAACG,OAAL,IAAgB,EAArC;;AACA,MAAI,OAAOD,cAAc,CAACE,MAAtB,KAAiC,WAArC,EAAkD;AAChDF,IAAAA,cAAc,CAACE,MAAf,GAAwBH,OAAxB;AACD;;AACD,MAAI,OAAOC,cAAc,CAACG,QAAtB,KAAmC,WAAvC,EAAoD;AAClDH,IAAAA,cAAc,CAACG,QAAf,GAA0BH,cAAc,CAACE,MAAf,GAAwB,MAAxB,GAAiC,KAA3D;AACD,GAV6E,CAY9E;;;AACA,MAAIF,cAAc,CAACE,MAAf,IAAyB,CAACH,OAA9B,EAAuC;AACrC;AACA,oBACE,oEACA,4DADA,GAEA,gEAHF;AAKAC,IAAAA,cAAc,CAACE,MAAf,GAAwB,KAAxB;AACD,GArB6E,CAuB9E;AACA;;;AACA,MAAIF,cAAc,CAACG,QAAf,KAA4B,MAA5B,IAAsC,CAACH,cAAc,CAACE,MAA1D,EAAkE;AAChEF,IAAAA,cAAc,CAACG,QAAf,GAA0B,KAA1B;AACD;;AAED,SAAOH,cAAP;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\n/* eslint-disable complexity */\nimport { StorageManagerOptions, OktaAuthOptions } from '../types';\nimport { warn } from '../util';\n\nexport { default as storage } from '../browser/browserStorage';\n\nexport const STORAGE_MANAGER_OPTIONS: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n cache: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n transaction: {\n storageTypes: [\n 'sessionStorage',\n 'localStorage',\n 'cookie'\n ]\n },\n 'shared-transaction': {\n storageTypes: [\n 'localStorage'\n ]\n },\n 'original-uri': {\n storageTypes: [\n 'localStorage'\n ]\n }\n};\n\nexport const enableSharedStorage = true;\n\nexport function getCookieSettings(args: OktaAuthOptions = {}, isHTTPS: boolean) {\n // Secure cookies will be automatically used on a HTTPS connection\n // Non-secure cookies will be automatically used on a HTTP connection\n // secure option can override the automatic behavior\n var cookieSettings = args.cookies || {};\n if (typeof cookieSettings.secure === 'undefined') {\n cookieSettings.secure = isHTTPS;\n }\n if (typeof cookieSettings.sameSite === 'undefined') {\n cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';\n }\n\n // If secure=true, but the connection is not HTTPS, set secure=false.\n if (cookieSettings.secure && !isHTTPS) {\n // eslint-disable-next-line no-console\n warn(\n 'The current page is not being served with the HTTPS protocol.\\n' +\n 'For security reasons, we strongly recommend using HTTPS.\\n' +\n 'If you cannot use HTTPS, set \"cookies.secure\" option to false.'\n );\n cookieSettings.secure = false;\n }\n\n // Chrome >= 80 will block cookies with SameSite=None unless they are also Secure\n // If sameSite=none, but the connection is not HTTPS, set sameSite=lax.\n if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {\n cookieSettings.sameSite = 'lax';\n }\n\n return cookieSettings;\n}\n"],"file":"browser.js"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ exports.getDefaultOptions = getDefaultOptions;
6
+ exports.buildOptions = buildOptions;
7
+
8
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
9
+
10
+ var _util = require("../util");
11
+
12
+ var _builderUtil = require("../builderUtil");
13
+
14
+ var _fetchRequest = _interopRequireDefault(require("../fetch/fetchRequest"));
15
+
16
+ var _node = require("./node");
17
+
18
+ var _features = require("../features");
19
+
20
+ /*!
21
+ * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
22
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
23
+ *
24
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ *
29
+ * See the License for the specific language governing permissions and limitations under the License.
30
+ */
31
+ function getDefaultOptions() {
32
+ const options = {
33
+ devMode: false,
34
+ httpRequestClient: _fetchRequest.default,
35
+ storageUtil: _node.storage,
36
+ storageManager: _node.STORAGE_MANAGER_OPTIONS,
37
+ transactionManager: {
38
+ enableSharedStorage: _node.enableSharedStorage
39
+ }
40
+ };
41
+ return options;
42
+ }
43
+
44
+ function mergeOptions(options, args) {
45
+ return (0, _assign.default)({}, options, (0, _util.removeNils)(args), {
46
+ storageManager: (0, _assign.default)({}, options.storageManager, args.storageManager),
47
+ transactionManager: (0, _assign.default)({}, options.transactionManager, args.transactionManager)
48
+ });
49
+ }
50
+
51
+ function buildOptions(args = {}) {
52
+ (0, _builderUtil.assertValidConfig)(args);
53
+ args = mergeOptions(getDefaultOptions(), args);
54
+ return (0, _util.removeNils)({
55
+ // OIDC configuration
56
+ issuer: (0, _util.removeTrailingSlash)(args.issuer),
57
+ tokenUrl: (0, _util.removeTrailingSlash)(args.tokenUrl),
58
+ authorizeUrl: (0, _util.removeTrailingSlash)(args.authorizeUrl),
59
+ userinfoUrl: (0, _util.removeTrailingSlash)(args.userinfoUrl),
60
+ revokeUrl: (0, _util.removeTrailingSlash)(args.revokeUrl),
61
+ logoutUrl: (0, _util.removeTrailingSlash)(args.logoutUrl),
62
+ clientId: args.clientId,
63
+ redirectUri: args.redirectUri,
64
+ state: args.state,
65
+ scopes: args.scopes,
66
+ postLogoutRedirectUri: args.postLogoutRedirectUri,
67
+ responseMode: args.responseMode,
68
+ responseType: args.responseType,
69
+ pkce: args.pkce === false ? false : true,
70
+ // PKCE defaults to true
71
+ useInteractionCodeFlow: args.useInteractionCodeFlow,
72
+ // Internal options
73
+ httpRequestClient: args.httpRequestClient,
74
+ transformErrorXHR: args.transformErrorXHR,
75
+ transformAuthState: args.transformAuthState,
76
+ restoreOriginalUri: args.restoreOriginalUri,
77
+ storageUtil: args.storageUtil,
78
+ headers: args.headers,
79
+ devMode: !!args.devMode,
80
+ storageManager: args.storageManager,
81
+ transactionManager: args.transactionManager,
82
+ cookies: (0, _node.getCookieSettings)(args, (0, _features.isHTTPS)()),
83
+ flow: args.flow,
84
+ codeChallenge: args.codeChallenge,
85
+ codeChallengeMethod: args.codeChallengeMethod,
86
+ recoveryToken: args.recoveryToken,
87
+ activationToken: args.activationToken,
88
+ // Give the developer the ability to disable token signature validation.
89
+ ignoreSignature: !!args.ignoreSignature,
90
+ // Server-side web applications
91
+ clientSecret: args.clientSecret
92
+ });
93
+ }
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../lib/options/index.ts"],"names":["getDefaultOptions","options","devMode","httpRequestClient","fetchRequest","storageUtil","storage","storageManager","STORAGE_MANAGER_OPTIONS","transactionManager","enableSharedStorage","mergeOptions","args","buildOptions","issuer","tokenUrl","authorizeUrl","userinfoUrl","revokeUrl","logoutUrl","clientId","redirectUri","state","scopes","postLogoutRedirectUri","responseMode","responseType","pkce","useInteractionCodeFlow","transformErrorXHR","transformAuthState","restoreOriginalUri","headers","cookies","flow","codeChallenge","codeChallengeMethod","recoveryToken","activationToken","ignoreSignature","clientSecret"],"mappings":";;;;;;;;;AAYA;;AACA;;AAGA;;AACA;;AACA;;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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BC,IAAAA,eAAe,EAAE1B,IAAI,CAAC0B,eAjCN;AAmChB;AACAC,IAAAA,eAAe,EAAE,CAAC,CAAC3B,IAAI,CAAC2B,eApCR;AAsChB;AACAC,IAAAA,YAAY,EAAE5B,IAAI,CAAC4B;AAvCH,GAAX,CAAP;AAyCD","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 { removeTrailingSlash, removeNils } from '../util';\nimport { assertValidConfig } from '../builderUtil';\nimport { OktaAuthOptions } from '../types';\n\nimport fetchRequest from '../fetch/fetchRequest';\nimport { storage, STORAGE_MANAGER_OPTIONS, enableSharedStorage, getCookieSettings } from './node';\nimport { isHTTPS } from '../features';\n\nexport function getDefaultOptions(): OktaAuthOptions {\n const options = {\n devMode: false,\n httpRequestClient: fetchRequest,\n storageUtil: storage,\n storageManager: STORAGE_MANAGER_OPTIONS,\n transactionManager: {\n enableSharedStorage\n }\n };\n return options;\n}\n\nfunction mergeOptions(options, args): OktaAuthOptions {\n return Object.assign({}, options, removeNils(args), {\n storageManager: Object.assign({}, options.storageManager, args.storageManager),\n transactionManager: Object.assign({}, options.transactionManager, args.transactionManager),\n });\n}\n\nexport function buildOptions(args: OktaAuthOptions = {}): OktaAuthOptions {\n assertValidConfig(args);\n args = mergeOptions(getDefaultOptions(), args);\n return removeNils({\n // OIDC configuration\n issuer: removeTrailingSlash(args.issuer),\n tokenUrl: removeTrailingSlash(args.tokenUrl),\n authorizeUrl: removeTrailingSlash(args.authorizeUrl),\n userinfoUrl: removeTrailingSlash(args.userinfoUrl),\n revokeUrl: removeTrailingSlash(args.revokeUrl),\n logoutUrl: removeTrailingSlash(args.logoutUrl),\n clientId: args.clientId,\n redirectUri: args.redirectUri,\n state: args.state,\n scopes: args.scopes,\n postLogoutRedirectUri: args.postLogoutRedirectUri,\n responseMode: args.responseMode,\n responseType: args.responseType,\n pkce: args.pkce === false ? false : true, // PKCE defaults to true\n useInteractionCodeFlow: args.useInteractionCodeFlow,\n\n // Internal options\n httpRequestClient: args.httpRequestClient,\n transformErrorXHR: args.transformErrorXHR,\n transformAuthState: args.transformAuthState,\n restoreOriginalUri: args.restoreOriginalUri,\n storageUtil: args.storageUtil,\n headers: args.headers,\n devMode: !!args.devMode,\n storageManager: args.storageManager,\n transactionManager: args.transactionManager,\n cookies: getCookieSettings(args, isHTTPS()),\n flow: args.flow,\n codeChallenge: args.codeChallenge,\n codeChallengeMethod: args.codeChallengeMethod,\n recoveryToken: args.recoveryToken,\n activationToken: args.activationToken,\n\n // Give the developer the ability to disable token signature validation.\n ignoreSignature: !!args.ignoreSignature,\n\n // Server-side web applications\n clientSecret: args.clientSecret\n });\n}\n"],"file":"index.js"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ exports.getCookieSettings = getCookieSettings;
6
+ Object.defineProperty(exports, "storage", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _serverStorage.default;
10
+ }
11
+ });
12
+ exports.enableSharedStorage = exports.STORAGE_MANAGER_OPTIONS = void 0;
13
+
14
+ var _serverStorage = _interopRequireDefault(require("../server/serverStorage"));
15
+
16
+ /*!
17
+ * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
18
+ * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
19
+ *
20
+ * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
23
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ *
25
+ * See the License for the specific language governing permissions and limitations under the License.
26
+ */
27
+ const STORAGE_MANAGER_OPTIONS = {
28
+ token: {
29
+ storageTypes: ['memory']
30
+ },
31
+ cache: {
32
+ storageTypes: ['memory']
33
+ },
34
+ transaction: {
35
+ storageTypes: ['memory']
36
+ }
37
+ };
38
+ exports.STORAGE_MANAGER_OPTIONS = STORAGE_MANAGER_OPTIONS;
39
+ const enableSharedStorage = false; // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
40
+
41
+ exports.enableSharedStorage = enableSharedStorage;
42
+
43
+ function getCookieSettings(args = {}, isHTTPS) {
44
+ return args.cookies;
45
+ }
46
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../lib/options/node.ts"],"names":["STORAGE_MANAGER_OPTIONS","token","storageTypes","cache","transaction","enableSharedStorage","getCookieSettings","args","isHTTPS","cookies"],"mappings":";;;;;;;;;;;;;AAcA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,MAAMA,uBAA8C,GAAG;AAC5DC,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GADqD;AAM5DC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GANqD;AAW5DE,EAAAA,WAAW,EAAE;AACXF,IAAAA,YAAY,EAAE,CACZ,QADY;AADH;AAX+C,CAAvD;;AAkBA,MAAMG,mBAAmB,GAAG,KAA5B,C,CAEP;;;;AACO,SAASC,iBAAT,CAA2BC,IAAqB,GAAG,EAAnD,EAAuDC,OAAvD,EAA0E;AAC/E,SAAOD,IAAI,CAACE,OAAZ;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 { StorageManagerOptions, OktaAuthOptions } from '../types';\n\nexport { default as storage } from '../server/serverStorage';\n\nexport const STORAGE_MANAGER_OPTIONS: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'memory'\n ]\n },\n cache: {\n storageTypes: [\n 'memory'\n ]\n },\n transaction: {\n storageTypes: [\n 'memory'\n ]\n }\n};\n\nexport const enableSharedStorage = false;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nexport function getCookieSettings(args: OktaAuthOptions = {}, isHTTPS?: boolean) {\n return args.cookies;\n}\n"],"file":"node.js"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  exports.default = void 0;
4
6
 
7
+ var _nodeCache = _interopRequireDefault(require("node-cache"));
8
+
5
9
  var _errors = require("../errors");
6
10
 
7
11
  /*!
@@ -16,11 +20,11 @@ var _errors = require("../errors");
16
20
  * See the License for the specific language governing permissions and limitations under the License.
17
21
  *
18
22
  */
19
- const NodeCache = require('node-cache'); // commonJS module cannot be imported without esModuleInterop
23
+ // @ts-ignore
24
+ // Do not use this type in code, so it won't be emitted in the declaration output
25
+ // eslint-disable-next-line import/no-commonjs
20
26
  // this is a SHARED memory storage to support a stateless http server
21
-
22
-
23
- const sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;
27
+ const sharedStorage = typeof _nodeCache.default === 'function' ? new _nodeCache.default() : null;
24
28
 
25
29
  class ServerCookies {
26
30
  // NodeCache
@@ -75,7 +79,7 @@ class ServerStorage {
75
79
  }
76
80
 
77
81
  getStorageByType(storageType) {
78
- let storageProvider = null;
82
+ let storageProvider;
79
83
 
80
84
  switch (storageType) {
81
85
  case 'memory':
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/server/serverStorage.ts"],"names":["NodeCache","require","sharedStorage","ServerCookies","constructor","nodeCache","set","name","value","expiresAt","Date","parse","ttl","now","get","delete","del","ServerStorage","storage","testStorageType","storageType","supported","getStorageByType","storageProvider","getStorage","AuthSdkError","findStorageType","getHttpCache","getItem","setItem","key"],"mappings":";;;;AAcA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,MAAMA,SAAS,GAAGC,OAAO,CAAC,YAAD,CAAzB,C,CAAyC;AAEzC;;;AACA,MAAMC,aAAa,GAAG,OAAOF,SAAP,KAAqB,UAArB,GAAkC,IAAIA,SAAJ,EAAlC,GAAoD,IAA1E;;AAEA,MAAMG,aAAN,CAAuC;AACrB;AAEhBC,EAAAA,WAAW,CAACC,SAAD,EAAY;AACrB,SAAKA,SAAL,GAAiBA,SAAjB;AACD;;AAEDC,EAAAA,GAAG,CAACC,IAAD,EAAeC,KAAf,EAA8BC,SAA9B,EAAyD;AAC1D;AACA,QAAI,CAAC,CAAEC,IAAI,CAACC,KAAL,CAAWF,SAAX,CAAP,EAA+B;AAC7B;AACA,UAAIG,GAAG,GAAG,CAACF,IAAI,CAACC,KAAL,CAAWF,SAAX,IAAwBC,IAAI,CAACG,GAAL,EAAzB,IAAuC,IAAjD;AACA,WAAKR,SAAL,CAAeC,GAAf,CAAmBC,IAAnB,EAAyBC,KAAzB,EAAgCI,GAAhC;AACD,KAJD,MAIO;AACL,WAAKP,SAAL,CAAeC,GAAf,CAAmBC,IAAnB,EAAyBC,KAAzB;AACD;;AAED,WAAO,KAAKM,GAAL,CAASP,IAAT,CAAP;AACD;;AAEDO,EAAAA,GAAG,CAACP,IAAD,EAAe;AAChB,WAAO,KAAKF,SAAL,CAAeS,GAAf,CAAmBP,IAAnB,CAAP;AACD;;AAEDQ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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 { SimpleStorage, StorageType, StorageUtil, Cookies } from '../types';\nimport { AuthSdkError } from '../errors';\nconst NodeCache = require('node-cache'); // commonJS module cannot be imported without esModuleInterop\n\n// this is a SHARED memory storage to support a stateless http server\nconst sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;\n\nclass ServerCookies implements Cookies {\n nodeCache: any; // NodeCache\n \n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n }\n\n set(name: string, value: string, expiresAt: string): string {\n // eslint-disable-next-line no-extra-boolean-cast\n if (!!(Date.parse(expiresAt))) {\n // Time to expiration in seconds\n var ttl = (Date.parse(expiresAt) - Date.now()) / 1000;\n this.nodeCache.set(name, value, ttl);\n } else {\n this.nodeCache.set(name, value);\n }\n\n return this.get(name);\n }\n\n get(name): string {\n return this.nodeCache.get(name);\n }\n\n delete(name) {\n return this.nodeCache.del(name);\n }\n}\n// Building this as an object allows us to mock the functions in our tests\nclass ServerStorage implements StorageUtil {\n nodeCache: any; // NodeCache\n storage: Cookies;\n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n this.storage = new ServerCookies(nodeCache);\n }\n\n testStorageType(storageType: StorageType): boolean {\n var supported = false;\n switch (storageType) {\n case 'memory':\n supported = true;\n break;\n default:\n break;\n }\n return supported;\n }\n\n getStorageByType(storageType: StorageType): SimpleStorage {\n let storageProvider = null;\n switch (storageType) {\n case 'memory':\n storageProvider = this.getStorage();\n break;\n default:\n throw new AuthSdkError(`Unrecognized storage option: ${storageType}`);\n break;\n }\n return storageProvider;\n }\n\n findStorageType(): StorageType {\n return 'memory';\n }\n\n // will be removed in next version. OKTA-362589\n getHttpCache() {\n return null; // stubbed in server.js\n }\n\n // shared in-memory using node cache\n getStorage(): SimpleStorage {\n return {\n getItem: this.nodeCache.get,\n setItem: (key, value) => {\n this.nodeCache.set(key, value, '2200-01-01T00:00:00.000Z');\n }\n };\n }\n}\n\nexport default new ServerStorage(sharedStorage);\n"],"file":"serverStorage.js"}
1
+ {"version":3,"sources":["../../../lib/server/serverStorage.ts"],"names":["sharedStorage","NodeCache","ServerCookies","constructor","nodeCache","set","name","value","expiresAt","Date","parse","ttl","now","get","delete","del","ServerStorage","storage","testStorageType","storageType","supported","getStorageByType","storageProvider","getStorage","AuthSdkError","findStorageType","getHttpCache","getItem","setItem","key"],"mappings":";;;;;;AAeA;;AAEA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AAEA;AACA,MAAMA,aAAa,GAAG,OAAOC,kBAAP,KAAqB,UAArB,GAAkC,IAAIA,kBAAJ,EAAlC,GAAoD,IAA1E;;AAEA,MAAMC,aAAN,CAAuC;AACrB;AAEhBC,EAAAA,WAAW,CAACC,SAAD,EAAY;AACrB,SAAKA,SAAL,GAAiBA,SAAjB;AACD;;AAEDC,EAAAA,GAAG,CAACC,IAAD,EAAeC,KAAf,EAA8BC,SAA9B,EAAyD;AAC1D;AACA,QAAI,CAAC,CAAEC,IAAI,CAACC,KAAL,CAAWF,SAAX,CAAP,EAA+B;AAC7B;AACA,UAAIG,GAAG,GAAG,CAACF,IAAI,CAACC,KAAL,CAAWF,SAAX,IAAwBC,IAAI,CAACG,GAAL,EAAzB,IAAuC,IAAjD;AACA,WAAKR,SAAL,CAAeC,GAAf,CAAmBC,IAAnB,EAAyBC,KAAzB,EAAgCI,GAAhC;AACD,KAJD,MAIO;AACL,WAAKP,SAAL,CAAeC,GAAf,CAAmBC,IAAnB,EAAyBC,KAAzB;AACD;;AAED,WAAO,KAAK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BtB,KAAxB,EAA+B,0BAA/B;AACD;AAJI,KAAP;AAMD;;AAlDwC;;eAqD5B,IAAIS,aAAJ,CAAkBhB,aAAlB,C","sourcesContent":["/*!\n * Copyright (c) 2018-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\n// @ts-ignore \n// Do not use this type in code, so it won't be emitted in the declaration output\nimport NodeCache from 'node-cache';\nimport { SimpleStorage, StorageType, StorageUtil, Cookies } from '../types';\nimport { AuthSdkError } from '../errors';\n// eslint-disable-next-line import/no-commonjs\n\n// this is a SHARED memory storage to support a stateless http server\nconst sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;\n\nclass ServerCookies implements Cookies {\n nodeCache: any; // NodeCache\n \n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n }\n\n set(name: string, value: string, expiresAt: string): string {\n // eslint-disable-next-line no-extra-boolean-cast\n if (!!(Date.parse(expiresAt))) {\n // Time to expiration in seconds\n var ttl = (Date.parse(expiresAt) - Date.now()) / 1000;\n this.nodeCache.set(name, value, ttl);\n } else {\n this.nodeCache.set(name, value);\n }\n\n return this.get(name);\n }\n\n get(name): string {\n return this.nodeCache.get(name);\n }\n\n delete(name) {\n return this.nodeCache.del(name);\n }\n}\n// Building this as an object allows us to mock the functions in our tests\nclass ServerStorage implements StorageUtil {\n nodeCache: any; // NodeCache\n storage: Cookies;\n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n this.storage = new ServerCookies(nodeCache);\n }\n\n testStorageType(storageType: StorageType): boolean {\n var supported = false;\n switch (storageType) {\n case 'memory':\n supported = true;\n break;\n default:\n break;\n }\n return supported;\n }\n\n getStorageByType(storageType: StorageType): SimpleStorage {\n let storageProvider;\n switch (storageType) {\n case 'memory':\n storageProvider = this.getStorage();\n break;\n default:\n throw new AuthSdkError(`Unrecognized storage option: ${storageType}`);\n break;\n }\n return storageProvider;\n }\n\n findStorageType(): StorageType {\n return 'memory';\n }\n\n // will be removed in next version. OKTA-362589\n getHttpCache() {\n return null; // stubbed in server.js\n }\n\n // shared in-memory using node cache\n getStorage(): SimpleStorage {\n return {\n getItem: this.nodeCache.get,\n setItem: (key, value) => {\n this.nodeCache.set(key, value, '2200-01-01T00:00:00.000Z');\n }\n };\n }\n}\n\nexport default new ServerStorage(sharedStorage);\n"],"file":"serverStorage.js"}