@okta/okta-auth-js 5.8.0 → 5.10.1
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.
- package/CHANGELOG.md +45 -0
- package/README.md +12 -2
- package/cjs/OktaAuth.js +34 -13
- package/cjs/OktaAuth.js.map +1 -1
- package/cjs/OktaUserAgent.js +2 -2
- package/cjs/OktaUserAgent.js.map +1 -1
- package/cjs/TokenManager.js +24 -2
- package/cjs/TokenManager.js.map +1 -1
- package/cjs/TransactionManager.js +6 -2
- package/cjs/TransactionManager.js.map +1 -1
- package/cjs/features.js +1 -1
- package/cjs/features.js.map +1 -1
- package/cjs/idx/authenticate.js +3 -18
- package/cjs/idx/authenticate.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js +14 -0
- package/cjs/idx/authenticator/Authenticator.js.map +1 -0
- package/cjs/idx/authenticator/OktaPassword.js +31 -0
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -0
- package/cjs/idx/authenticator/OktaVerifyTotp.js +17 -0
- package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -0
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +50 -0
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -0
- package/cjs/idx/authenticator/SecurityQuestionVerification.js +31 -0
- package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -0
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +34 -0
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -0
- package/cjs/idx/authenticator/getAuthenticator.js +42 -0
- package/cjs/idx/authenticator/getAuthenticator.js.map +1 -0
- package/cjs/idx/authenticator/index.js +80 -0
- package/cjs/idx/authenticator/index.js.map +1 -0
- package/cjs/idx/cancel.js +5 -0
- package/cjs/idx/cancel.js.map +1 -1
- package/cjs/idx/flow/AuthenticationFlow.js +32 -0
- package/cjs/idx/flow/AuthenticationFlow.js.map +1 -0
- package/cjs/idx/flow/FlowSpecification.js +39 -0
- package/cjs/idx/flow/FlowSpecification.js.map +1 -0
- package/cjs/idx/flow/PasswordRecoveryFlow.js +28 -0
- package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -0
- package/{esm/crypto/browser.js → cjs/idx/flow/RegistrationFlow.js} +16 -12
- package/cjs/idx/flow/RegistrationFlow.js.map +1 -0
- package/cjs/idx/flow/RemediationFlow.js +2 -0
- package/{esm/types/Cookies.js.map → cjs/idx/flow/RemediationFlow.js.map} +1 -1
- package/cjs/idx/flow/index.js +67 -0
- package/cjs/idx/flow/index.js.map +1 -0
- package/cjs/idx/index.js +39 -0
- package/cjs/idx/index.js.map +1 -1
- package/cjs/idx/interact.js +8 -2
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/poll.js +59 -0
- package/cjs/idx/poll.js.map +1 -0
- package/cjs/idx/proceed.js +49 -0
- package/cjs/idx/proceed.js.map +1 -0
- package/cjs/idx/recoverPassword.js +3 -17
- package/cjs/idx/recoverPassword.js.map +1 -1
- package/cjs/idx/register.js +22 -20
- package/cjs/idx/register.js.map +1 -1
- package/cjs/idx/remediate.js +40 -93
- package/cjs/idx/remediate.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +9 -12
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +6 -9
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +43 -32
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +51 -20
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +16 -16
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +8 -28
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/{esm/idx/remediators/RedirectIdp.js → cjs/idx/remediators/ChallengePoll.js} +13 -25
- package/cjs/idx/remediators/ChallengePoll.js.map +1 -0
- package/cjs/idx/remediators/EnrollPoll.js +56 -0
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -0
- package/cjs/idx/remediators/Identify.js +4 -36
- package/cjs/idx/remediators/Identify.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +23 -2
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/Skip.js +7 -0
- package/cjs/idx/remediators/Skip.js.map +1 -1
- package/cjs/idx/remediators/index.js +26 -0
- package/cjs/idx/remediators/index.js.map +1 -1
- package/cjs/idx/run.js +18 -20
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/startTransaction.js +2 -0
- package/cjs/idx/startTransaction.js.map +1 -1
- package/cjs/idx/transactionMeta.js +67 -42
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/types/FlowIdentifier.js +2 -0
- package/{esm/types/AuthState.js.map → cjs/idx/types/FlowIdentifier.js.map} +1 -1
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/types/index.js +18 -1
- package/cjs/idx/types/index.js.map +1 -1
- package/cjs/oidc/endpoints/authorize.js +4 -1
- package/cjs/oidc/endpoints/authorize.js.map +1 -1
- package/cjs/types/Token.js.map +1 -1
- package/cjs/types/Transaction.js.map +1 -1
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.umd.js +1 -1
- package/dist/okta-auth-js.umd.js.map +1 -1
- package/esm/index.js +8580 -16
- package/esm/index.js.map +1 -1
- package/lib/TokenManager.d.ts +2 -0
- package/lib/TransactionManager.d.ts +1 -0
- package/lib/idx/authenticator/Authenticator.d.ts +12 -0
- package/lib/idx/authenticator/OktaPassword.d.ts +11 -0
- package/lib/idx/authenticator/OktaVerifyTotp.d.ts +9 -0
- package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +28 -0
- package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +14 -0
- package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +10 -0
- package/lib/idx/authenticator/getAuthenticator.d.ts +3 -0
- package/lib/idx/authenticator/index.d.ts +6 -0
- package/{esm/crypto/webcrypto.js → lib/idx/flow/AuthenticationFlow.d.ts} +3 -4
- package/lib/idx/flow/FlowSpecification.d.ts +8 -0
- package/{esm/oidc/endpoints/index.js → lib/idx/flow/PasswordRecoveryFlow.d.ts} +3 -5
- package/{esm/tx/TransactionState.js → lib/idx/flow/RegistrationFlow.d.ts} +3 -3
- package/{esm/crypto/index.js → lib/idx/flow/RemediationFlow.d.ts} +3 -6
- package/lib/idx/{flowMonitors → flow}/index.d.ts +5 -4
- package/lib/idx/index.d.ts +3 -0
- package/lib/idx/interact.d.ts +1 -0
- package/lib/idx/poll.d.ts +13 -0
- package/lib/idx/proceed.d.ts +21 -0
- package/lib/idx/register.d.ts +1 -1
- package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +9 -5
- package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +0 -1
- package/lib/idx/remediators/Base/AuthenticatorData.d.ts +8 -3
- package/lib/idx/remediators/Base/Remediator.d.ts +9 -6
- package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +5 -4
- package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +8 -4
- package/lib/idx/remediators/ChallengePoll.d.ts +15 -0
- package/{esm/tx/util.js → lib/idx/remediators/EnrollPoll.d.ts} +11 -13
- package/lib/idx/remediators/Identify.d.ts +1 -3
- package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +6 -2
- package/lib/idx/remediators/Skip.d.ts +3 -0
- package/lib/idx/remediators/index.d.ts +2 -0
- package/lib/idx/run.d.ts +8 -10
- package/lib/idx/transactionMeta.d.ts +24 -1
- package/lib/idx/types/FlowIdentifier.d.ts +1 -0
- package/lib/idx/types/idx-js.d.ts +52 -1
- package/lib/idx/types/index.d.ts +16 -3
- package/lib/types/OktaAuthOptions.d.ts +3 -0
- package/lib/types/Token.d.ts +1 -0
- package/lib/types/Transaction.d.ts +2 -0
- package/lib/types/api.d.ts +15 -2
- package/package.json +16 -8
- package/cjs/idx/flowMonitors/AuthenticationFlowMonitor.js +0 -45
- package/cjs/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
- package/cjs/idx/flowMonitors/FlowMonitor.js +0 -69
- package/cjs/idx/flowMonitors/FlowMonitor.js.map +0 -1
- package/cjs/idx/flowMonitors/PasswordRecoveryFlowMonitor.js +0 -55
- package/cjs/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
- package/cjs/idx/flowMonitors/RegistrationFlowMonitor.js +0 -35
- package/cjs/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
- package/cjs/idx/flowMonitors/index.js +0 -54
- package/cjs/idx/flowMonitors/index.js.map +0 -1
- package/esm/AuthStateManager.js +0 -214
- package/esm/AuthStateManager.js.map +0 -1
- package/esm/OktaAuth.js +0 -705
- package/esm/OktaAuth.js.map +0 -1
- package/esm/OktaUserAgent.js +0 -49
- package/esm/OktaUserAgent.js.map +0 -1
- package/esm/PromiseQueue.js +0 -71
- package/esm/PromiseQueue.js.map +0 -1
- package/esm/SavedObject.js +0 -91
- package/esm/SavedObject.js.map +0 -1
- package/esm/StorageManager.js +0 -190
- package/esm/StorageManager.js.map +0 -1
- package/esm/TokenManager.js +0 -455
- package/esm/TokenManager.js.map +0 -1
- package/esm/TransactionManager.js +0 -324
- package/esm/TransactionManager.js.map +0 -1
- package/esm/browser/browserStorage.js +0 -256
- package/esm/browser/browserStorage.js.map +0 -1
- package/esm/browser/fingerprint.js +0 -74
- package/esm/browser/fingerprint.js.map +0 -1
- package/esm/builderUtil.js +0 -56
- package/esm/builderUtil.js.map +0 -1
- package/esm/clock.js +0 -32
- package/esm/clock.js.map +0 -1
- package/esm/constants.js +0 -36
- package/esm/constants.js.map +0 -1
- package/esm/crypto/base64.js +0 -66
- package/esm/crypto/base64.js.map +0 -1
- package/esm/crypto/browser.js.map +0 -1
- package/esm/crypto/index.js.map +0 -1
- package/esm/crypto/node.js +0 -54
- package/esm/crypto/node.js.map +0 -1
- package/esm/crypto/oidcHash.js +0 -27
- package/esm/crypto/oidcHash.js.map +0 -1
- package/esm/crypto/verifyToken.js +0 -39
- package/esm/crypto/verifyToken.js.map +0 -1
- package/esm/crypto/webcrypto.js.map +0 -1
- package/esm/errors/AuthApiError.js +0 -30
- package/esm/errors/AuthApiError.js.map +0 -1
- package/esm/errors/AuthPollStopError.js +0 -20
- package/esm/errors/AuthPollStopError.js.map +0 -1
- package/esm/errors/AuthSdkError.js +0 -29
- package/esm/errors/AuthSdkError.js.map +0 -1
- package/esm/errors/CustomError.js +0 -21
- package/esm/errors/CustomError.js.map +0 -1
- package/esm/errors/OAuthError.js +0 -22
- package/esm/errors/OAuthError.js.map +0 -1
- package/esm/errors/index.js +0 -22
- package/esm/errors/index.js.map +0 -1
- package/esm/features.js +0 -64
- package/esm/features.js.map +0 -1
- package/esm/fetch/fetchRequest.js +0 -92
- package/esm/fetch/fetchRequest.js.map +0 -1
- package/esm/http/headers.js +0 -17
- package/esm/http/headers.js.map +0 -1
- package/esm/http/index.js +0 -3
- package/esm/http/index.js.map +0 -1
- package/esm/http/request.js +0 -145
- package/esm/http/request.js.map +0 -1
- package/esm/idx/authenticate.js +0 -47
- package/esm/idx/authenticate.js.map +0 -1
- package/esm/idx/cancel.js +0 -32
- package/esm/idx/cancel.js.map +0 -1
- package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js +0 -41
- package/esm/idx/flowMonitors/AuthenticationFlowMonitor.js.map +0 -1
- package/esm/idx/flowMonitors/FlowMonitor.js +0 -73
- package/esm/idx/flowMonitors/FlowMonitor.js.map +0 -1
- package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js +0 -57
- package/esm/idx/flowMonitors/PasswordRecoveryFlowMonitor.js.map +0 -1
- package/esm/idx/flowMonitors/RegistrationFlowMonitor.js +0 -28
- package/esm/idx/flowMonitors/RegistrationFlowMonitor.js.map +0 -1
- package/esm/idx/flowMonitors/index.js +0 -16
- package/esm/idx/flowMonitors/index.js.map +0 -1
- package/esm/idx/handleInteractionCodeRedirect.js +0 -64
- package/esm/idx/handleInteractionCodeRedirect.js.map +0 -1
- package/esm/idx/headers.js +0 -39
- package/esm/idx/headers.js.map +0 -1
- package/esm/idx/index.js +0 -20
- package/esm/idx/index.js.map +0 -1
- package/esm/idx/interact.js +0 -86
- package/esm/idx/interact.js.map +0 -1
- package/esm/idx/introspect.js +0 -61
- package/esm/idx/introspect.js.map +0 -1
- package/esm/idx/recoverPassword.js +0 -46
- package/esm/idx/recoverPassword.js.map +0 -1
- package/esm/idx/register.js +0 -63
- package/esm/idx/register.js.map +0 -1
- package/esm/idx/remediate.js +0 -302
- package/esm/idx/remediate.js.map +0 -1
- package/esm/idx/remediators/AuthenticatorEnrollmentData.js +0 -68
- package/esm/idx/remediators/AuthenticatorEnrollmentData.js.map +0 -1
- package/esm/idx/remediators/AuthenticatorVerificationData.js +0 -66
- package/esm/idx/remediators/AuthenticatorVerificationData.js.map +0 -1
- package/esm/idx/remediators/Base/AuthenticatorData.js +0 -105
- package/esm/idx/remediators/Base/AuthenticatorData.js.map +0 -1
- package/esm/idx/remediators/Base/Remediator.js +0 -221
- package/esm/idx/remediators/Base/Remediator.js.map +0 -1
- package/esm/idx/remediators/Base/SelectAuthenticator.js +0 -140
- package/esm/idx/remediators/Base/SelectAuthenticator.js.map +0 -1
- package/esm/idx/remediators/Base/VerifyAuthenticator.js +0 -65
- package/esm/idx/remediators/Base/VerifyAuthenticator.js.map +0 -1
- package/esm/idx/remediators/ChallengeAuthenticator.js +0 -18
- package/esm/idx/remediators/ChallengeAuthenticator.js.map +0 -1
- package/esm/idx/remediators/EnrollAuthenticator.js +0 -18
- package/esm/idx/remediators/EnrollAuthenticator.js.map +0 -1
- package/esm/idx/remediators/EnrollProfile.js +0 -79
- package/esm/idx/remediators/EnrollProfile.js.map +0 -1
- package/esm/idx/remediators/Identify.js +0 -87
- package/esm/idx/remediators/Identify.js.map +0 -1
- package/esm/idx/remediators/ReEnrollAuthenticator.js +0 -45
- package/esm/idx/remediators/ReEnrollAuthenticator.js.map +0 -1
- package/esm/idx/remediators/RedirectIdp.js.map +0 -1
- package/esm/idx/remediators/ResetAuthenticator.js +0 -18
- package/esm/idx/remediators/ResetAuthenticator.js.map +0 -1
- package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js +0 -18
- package/esm/idx/remediators/SelectAuthenticatorAuthenticate.js.map +0 -1
- package/esm/idx/remediators/SelectAuthenticatorEnroll.js +0 -18
- package/esm/idx/remediators/SelectAuthenticatorEnroll.js.map +0 -1
- package/esm/idx/remediators/SelectEnrollProfile.js +0 -24
- package/esm/idx/remediators/SelectEnrollProfile.js.map +0 -1
- package/esm/idx/remediators/Skip.js +0 -23
- package/esm/idx/remediators/Skip.js.map +0 -1
- package/esm/idx/remediators/index.js +0 -26
- package/esm/idx/remediators/index.js.map +0 -1
- package/esm/idx/remediators/util.js +0 -35
- package/esm/idx/remediators/util.js.map +0 -1
- package/esm/idx/run.js +0 -222
- package/esm/idx/run.js.map +0 -1
- package/esm/idx/startTransaction.js +0 -27
- package/esm/idx/startTransaction.js.map +0 -1
- package/esm/idx/transactionMeta.js +0 -125
- package/esm/idx/transactionMeta.js.map +0 -1
- package/esm/idx/types/idx-js.js +0 -20
- package/esm/idx/types/idx-js.js.map +0 -1
- package/esm/idx/types/index.js +0 -44
- package/esm/idx/types/index.js.map +0 -1
- package/esm/oidc/decodeToken.js +0 -31
- package/esm/oidc/decodeToken.js.map +0 -1
- package/esm/oidc/endpoints/authorize.js +0 -61
- package/esm/oidc/endpoints/authorize.js.map +0 -1
- package/esm/oidc/endpoints/index.js.map +0 -1
- package/esm/oidc/endpoints/token.js +0 -97
- package/esm/oidc/endpoints/token.js.map +0 -1
- package/esm/oidc/endpoints/well-known.js +0 -58
- package/esm/oidc/endpoints/well-known.js.map +0 -1
- package/esm/oidc/exchangeCodeForTokens.js +0 -69
- package/esm/oidc/exchangeCodeForTokens.js.map +0 -1
- package/esm/oidc/getToken.js +0 -180
- package/esm/oidc/getToken.js.map +0 -1
- package/esm/oidc/getUserInfo.js +0 -82
- package/esm/oidc/getUserInfo.js.map +0 -1
- package/esm/oidc/getWithPopup.js +0 -34
- package/esm/oidc/getWithPopup.js.map +0 -1
- package/esm/oidc/getWithRedirect.js +0 -61
- package/esm/oidc/getWithRedirect.js.map +0 -1
- package/esm/oidc/getWithoutPrompt.js +0 -29
- package/esm/oidc/getWithoutPrompt.js.map +0 -1
- package/esm/oidc/handleOAuthResponse.js +0 -148
- package/esm/oidc/handleOAuthResponse.js.map +0 -1
- package/esm/oidc/index.js +0 -29
- package/esm/oidc/index.js.map +0 -1
- package/esm/oidc/parseFromUrl.js +0 -144
- package/esm/oidc/parseFromUrl.js.map +0 -1
- package/esm/oidc/renewToken.js +0 -85
- package/esm/oidc/renewToken.js.map +0 -1
- package/esm/oidc/renewTokens.js +0 -74
- package/esm/oidc/renewTokens.js.map +0 -1
- package/esm/oidc/renewTokensWithRefresh.js +0 -55
- package/esm/oidc/renewTokensWithRefresh.js.map +0 -1
- package/esm/oidc/revokeToken.js +0 -57
- package/esm/oidc/revokeToken.js.map +0 -1
- package/esm/oidc/util/browser.js +0 -74
- package/esm/oidc/util/browser.js.map +0 -1
- package/esm/oidc/util/defaultTokenParams.js +0 -42
- package/esm/oidc/util/defaultTokenParams.js.map +0 -1
- package/esm/oidc/util/errors.js +0 -31
- package/esm/oidc/util/errors.js.map +0 -1
- package/esm/oidc/util/index.js +0 -25
- package/esm/oidc/util/index.js.map +0 -1
- package/esm/oidc/util/loginRedirect.js +0 -88
- package/esm/oidc/util/loginRedirect.js.map +0 -1
- package/esm/oidc/util/oauth.js +0 -70
- package/esm/oidc/util/oauth.js.map +0 -1
- package/esm/oidc/util/pkce.js +0 -55
- package/esm/oidc/util/pkce.js.map +0 -1
- package/esm/oidc/util/prepareTokenParams.js +0 -75
- package/esm/oidc/util/prepareTokenParams.js.map +0 -1
- package/esm/oidc/util/refreshToken.js +0 -24
- package/esm/oidc/util/refreshToken.js.map +0 -1
- package/esm/oidc/util/urlParams.js +0 -54
- package/esm/oidc/util/urlParams.js.map +0 -1
- package/esm/oidc/util/validateClaims.js +0 -53
- package/esm/oidc/util/validateClaims.js.map +0 -1
- package/esm/oidc/util/validateToken.js +0 -21
- package/esm/oidc/util/validateToken.js.map +0 -1
- package/esm/oidc/verifyToken.js +0 -78
- package/esm/oidc/verifyToken.js.map +0 -1
- package/esm/options.js +0 -144
- package/esm/options.js.map +0 -1
- package/esm/server/serverStorage.js +0 -111
- package/esm/server/serverStorage.js.map +0 -1
- package/esm/services/TokenService.js +0 -103
- package/esm/services/TokenService.js.map +0 -1
- package/esm/session.js +0 -81
- package/esm/session.js.map +0 -1
- package/esm/tx/AuthTransaction.js +0 -213
- package/esm/tx/AuthTransaction.js.map +0 -1
- package/esm/tx/TransactionState.js.map +0 -1
- package/esm/tx/api.js +0 -87
- package/esm/tx/api.js.map +0 -1
- package/esm/tx/index.js +0 -18
- package/esm/tx/index.js.map +0 -1
- package/esm/tx/poll.js +0 -124
- package/esm/tx/poll.js.map +0 -1
- package/esm/tx/util.js.map +0 -1
- package/esm/types/AuthState.js +0 -3
- package/esm/types/Cookies.js +0 -3
- package/esm/types/EventEmitter.js +0 -3
- package/esm/types/EventEmitter.js.map +0 -1
- package/esm/types/JWT.js +0 -3
- package/esm/types/JWT.js.map +0 -1
- package/esm/types/OAuth.js +0 -3
- package/esm/types/OAuth.js.map +0 -1
- package/esm/types/OktaAuthOptions.js +0 -3
- package/esm/types/OktaAuthOptions.js.map +0 -1
- package/esm/types/Storage.js +0 -3
- package/esm/types/Storage.js.map +0 -1
- package/esm/types/Token.js +0 -29
- package/esm/types/Token.js.map +0 -1
- package/esm/types/TokenManager.js +0 -3
- package/esm/types/TokenManager.js.map +0 -1
- package/esm/types/Transaction.js +0 -57
- package/esm/types/Transaction.js.map +0 -1
- package/esm/types/UserClaims.js +0 -3
- package/esm/types/UserClaims.js.map +0 -1
- package/esm/types/api.js +0 -3
- package/esm/types/api.js.map +0 -1
- package/esm/types/http.js +0 -3
- package/esm/types/http.js.map +0 -1
- package/esm/types/index.js +0 -27
- package/esm/types/index.js.map +0 -1
- package/esm/util/console.js +0 -53
- package/esm/util/console.js.map +0 -1
- package/esm/util/emailVerify.js +0 -21
- package/esm/util/emailVerify.js.map +0 -1
- package/esm/util/index.js +0 -18
- package/esm/util/index.js.map +0 -1
- package/esm/util/misc.js +0 -33
- package/esm/util/misc.js.map +0 -1
- package/esm/util/object.js +0 -117
- package/esm/util/object.js.map +0 -1
- package/esm/util/sharedStorage.js +0 -43
- package/esm/util/sharedStorage.js.map +0 -1
- package/esm/util/types.js +0 -27
- package/esm/util/types.js.map +0 -1
- package/esm/util/url.js +0 -64
- package/esm/util/url.js.map +0 -1
- package/lib/idx/flowMonitors/AuthenticationFlowMonitor.d.ts +0 -15
- package/lib/idx/flowMonitors/FlowMonitor.d.ts +0 -23
- package/lib/idx/flowMonitors/PasswordRecoveryFlowMonitor.d.ts +0 -16
- package/lib/idx/flowMonitors/RegistrationFlowMonitor.d.ts +0 -15
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { AuthSdkError } from '../../errors';
|
|
13
|
-
import { removeNils, toQueryString } from '../../util';
|
|
14
|
-
import { httpRequest } from '../../http';
|
|
15
|
-
|
|
16
|
-
function validateOptions(options) {
|
|
17
|
-
// Quick validation
|
|
18
|
-
if (!options.clientId) {
|
|
19
|
-
throw new AuthSdkError('A clientId must be specified in the OktaAuth constructor to get a token');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!options.redirectUri) {
|
|
23
|
-
throw new AuthSdkError('The redirectUri passed to /authorize must also be passed to /token');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!options.authorizationCode && !options.interactionCode) {
|
|
27
|
-
throw new AuthSdkError('An authorization code (returned from /authorize) must be passed to /token');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!options.codeVerifier) {
|
|
31
|
-
throw new AuthSdkError('The "codeVerifier" (generated and saved by your app) must be passed to /token');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getPostData(sdk, options) {
|
|
36
|
-
// Convert Token params to OAuth params, sent to the /token endpoint
|
|
37
|
-
var params = removeNils({
|
|
38
|
-
'client_id': options.clientId,
|
|
39
|
-
'redirect_uri': options.redirectUri,
|
|
40
|
-
'grant_type': options.interactionCode ? 'interaction_code' : 'authorization_code',
|
|
41
|
-
'code_verifier': options.codeVerifier
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
if (options.interactionCode) {
|
|
45
|
-
params['interaction_code'] = options.interactionCode;
|
|
46
|
-
} else if (options.authorizationCode) {
|
|
47
|
-
params.code = options.authorizationCode;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var {
|
|
51
|
-
clientSecret
|
|
52
|
-
} = sdk.options;
|
|
53
|
-
|
|
54
|
-
if (clientSecret) {
|
|
55
|
-
params['client_secret'] = clientSecret;
|
|
56
|
-
} // Encode as URL string
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return toQueryString(params).slice(1);
|
|
60
|
-
} // exchange authorization code for an access token
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export function postToTokenEndpoint(sdk, options, urls) {
|
|
64
|
-
validateOptions(options);
|
|
65
|
-
var data = getPostData(sdk, options);
|
|
66
|
-
var headers = {
|
|
67
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
68
|
-
};
|
|
69
|
-
return httpRequest(sdk, {
|
|
70
|
-
url: urls.tokenUrl,
|
|
71
|
-
method: 'POST',
|
|
72
|
-
args: data,
|
|
73
|
-
headers
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
export function postRefreshToken(sdk, options, refreshToken) {
|
|
77
|
-
return httpRequest(sdk, {
|
|
78
|
-
url: refreshToken.tokenUrl,
|
|
79
|
-
method: 'POST',
|
|
80
|
-
headers: {
|
|
81
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
82
|
-
},
|
|
83
|
-
args: Object.entries({
|
|
84
|
-
client_id: options.clientId,
|
|
85
|
-
// eslint-disable-line camelcase
|
|
86
|
-
grant_type: 'refresh_token',
|
|
87
|
-
// eslint-disable-line camelcase
|
|
88
|
-
scope: refreshToken.scopes.join(' '),
|
|
89
|
-
refresh_token: refreshToken.refreshToken // eslint-disable-line camelcase
|
|
90
|
-
|
|
91
|
-
}).map(function (_ref) {
|
|
92
|
-
var [name, value] = _ref;
|
|
93
|
-
return name + '=' + encodeURIComponent(value);
|
|
94
|
-
}).join('&')
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=token.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../lib/oidc/endpoints/token.ts"],"names":["AuthSdkError","removeNils","toQueryString","httpRequest","validateOptions","options","clientId","redirectUri","authorizationCode","interactionCode","codeVerifier","getPostData","sdk","params","code","clientSecret","slice","postToTokenEndpoint","urls","data","headers","url","tokenUrl","method","args","postRefreshToken","refreshToken","Object","entries","client_id","grant_type","scope","scopes","join","refresh_token","map","name","value","encodeURIComponent"],"mappings":"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","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 } 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(sdk, options: TokenParams, refreshToken: RefreshToken): 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 return name + '=' + encodeURIComponent(value);\n }).join('&'),\n });\n}"],"file":"token.js"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
import { get } from '../../http';
|
|
14
|
-
import { find } from '../../util';
|
|
15
|
-
import AuthSdkError from '../../errors/AuthSdkError';
|
|
16
|
-
export function getWellKnown(sdk, issuer) {
|
|
17
|
-
var authServerUri = issuer || sdk.options.issuer;
|
|
18
|
-
return get(sdk, authServerUri + '/.well-known/openid-configuration', {
|
|
19
|
-
cacheResponse: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function getKey(sdk, issuer, kid) {
|
|
23
|
-
var httpCache = sdk.storageManager.getHttpCache(sdk.options.cookies);
|
|
24
|
-
return getWellKnown(sdk, issuer).then(function (wellKnown) {
|
|
25
|
-
var jwksUri = wellKnown['jwks_uri']; // Check our kid against the cached version (if it exists and isn't expired)
|
|
26
|
-
|
|
27
|
-
var cacheContents = httpCache.getStorage();
|
|
28
|
-
var cachedResponse = cacheContents[jwksUri];
|
|
29
|
-
|
|
30
|
-
if (cachedResponse && Date.now() / 1000 < cachedResponse.expiresAt) {
|
|
31
|
-
var cachedKey = find(cachedResponse.response.keys, {
|
|
32
|
-
kid: kid
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (cachedKey) {
|
|
36
|
-
return cachedKey;
|
|
37
|
-
}
|
|
38
|
-
} // Remove cache for the key
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
httpCache.clearStorage(jwksUri); // Pull the latest keys if the key wasn't in the cache
|
|
42
|
-
|
|
43
|
-
return get(sdk, jwksUri, {
|
|
44
|
-
cacheResponse: true
|
|
45
|
-
}).then(function (res) {
|
|
46
|
-
var key = find(res.keys, {
|
|
47
|
-
kid: kid
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (key) {
|
|
51
|
-
return key;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw new AuthSdkError('The key id, ' + kid + ', was not found in the server\'s keys');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=well-known.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../lib/oidc/endpoints/well-known.ts"],"names":["get","find","AuthSdkError","getWellKnown","sdk","issuer","authServerUri","options","cacheResponse","getKey","kid","httpCache","storageManager","getHttpCache","cookies","then","wellKnown","jwksUri","cacheContents","getStorage","cachedResponse","Date","now","expiresAt","cachedKey","response","keys","clearStorage","res","key"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,YAApB;AACA,SAASC,IAAT,QAAqB,YAArB;AAEA,OAAOC,YAAP,MAAyB,2BAAzB;AAEA,OAAO,SAASC,YAAT,CAAsBC,GAAtB,EAAqCC,MAArC,EAAkF;AACvF,MAAIC,aAAa,GAAID,MAAM,IAAID,GAAG,CAACG,OAAJ,CAAYF,MAA3C;AACA,SAAOL,GAAG,CAACI,GAAD,EAAME,aAAa,GAAG,mCAAtB,EAA2D;AACnEE,IAAAA,aAAa,EAAE;AADoD,GAA3D,CAAV;AAGD;AAED,OAAO,SAASC,MAAT,CAAgBL,GAAhB,EAA+BC,MAA/B,EAA+CK,GAA/C,EAA6E;AAClF,MAAIC,SAAS,GAAGP,GAAG,CAACQ,cAAJ,CAAmBC,YAAnB,CAAgCT,GAAG,CAACG,OAAJ,CAAYO,OAA5C,CAAhB;AAEA,SAAOX,YAAY,CAACC,GAAD,EAAMC,MAAN,CAAZ,CACNU,IADM,CACD,UAASC,SAAT,EAAoB;AACxB,QAAIC,OAAO,GAAGD,SAAS,CAAC,UAAD,CAAvB,CADwB,CAGxB;;AACA,QAAIE,aAAa,GAAGP,SAAS,CAACQ,UAAV,EAApB;AACA,QAAIC,cAAc,GAAGF,aAAa,CAACD,OAAD,CAAlC;;AACA,QAAIG,cAAc,IAAIC,IAAI,CAACC,GAAL,KAAW,IAAX,GAAkBF,cAAc,CAACG,SAAvD,EAAkE;AAChE,UAAIC,SAAS,GAAGvB,IAAI,CAACmB,cAAc,CAACK,QAAf,CAAwBC,IAAzB,EAA+B;AACjDhB,QAAAA,GAAG,EAAEA;AAD4C,OAA/B,CAApB;;AAIA,UAAIc,SAAJ,EAAe;AACb,eAAOA,SAAP;AACD;AACF,KAduB,CAgBxB;;;AACAb,IAAAA,SAAS,CAACgB,YAAV,CAAuBV,OAAvB,EAjBwB,CAmBxB;;AACA,WAAOjB,GAAG,CAACI,GAAD,EAAMa,OAAN,EAAe;AACvBT,MAAAA,aAAa,EAAE;AADQ,KAAf,CAAH,CAGNO,IAHM,CAGD,UAASa,GAAT,EAAc;AAClB,UAAIC,GAAG,GAAG5B,IAAI,CAAC2B,GAAG,CAACF,IAAL,EAAW;AACvBhB,QAAAA,GAAG,EAAEA;AADkB,OAAX,CAAd;;AAIA,UAAImB,GAAJ,EAAS;AACP,eAAOA,GAAP;AACD;;AAED,YAAM,IAAI3B,YAAJ,CAAiB,iBAAiBQ,GAAjB,GAAuB,uCAAxC,CAAN;AACD,KAbM,CAAP;AAcD,GAnCM,CAAP;AAoCD","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 { get } from '../../http';\nimport { find } from '../../util';\nimport { OktaAuth, WellKnownResponse } from '../../types';\nimport AuthSdkError from '../../errors/AuthSdkError';\n\nexport function getWellKnown(sdk: OktaAuth, issuer?: string): Promise<WellKnownResponse> {\n var authServerUri = (issuer || sdk.options.issuer);\n return get(sdk, authServerUri + '/.well-known/openid-configuration', {\n cacheResponse: true\n });\n}\n\nexport function getKey(sdk: OktaAuth, issuer: string, kid: string): Promise<string> {\n var httpCache = sdk.storageManager.getHttpCache(sdk.options.cookies);\n\n return getWellKnown(sdk, issuer)\n .then(function(wellKnown) {\n var jwksUri = wellKnown['jwks_uri'];\n\n // Check our kid against the cached version (if it exists and isn't expired)\n var cacheContents = httpCache.getStorage();\n var cachedResponse = cacheContents[jwksUri];\n if (cachedResponse && Date.now()/1000 < cachedResponse.expiresAt) {\n var cachedKey = find(cachedResponse.response.keys, {\n kid: kid\n });\n\n if (cachedKey) {\n return cachedKey;\n }\n }\n\n // Remove cache for the key\n httpCache.clearStorage(jwksUri);\n\n // Pull the latest keys if the key wasn't in the cache\n return get(sdk, jwksUri, {\n cacheResponse: true\n })\n .then(function(res) {\n var key = find(res.keys, {\n kid: kid\n });\n\n if (key) {\n return key;\n }\n\n throw new AuthSdkError('The key id, ' + kid + ', was not found in the server\\'s keys');\n });\n });\n}\n"],"file":"well-known.js"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
|
|
3
|
-
/*!
|
|
4
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
5
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
6
|
-
*
|
|
7
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
10
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
*
|
|
12
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
import { getOAuthUrls } from '../oidc';
|
|
16
|
-
import { getDefaultTokenParams } from './util';
|
|
17
|
-
import { clone } from '../util';
|
|
18
|
-
import { postToTokenEndpoint } from './endpoints/token';
|
|
19
|
-
import { handleOAuthResponse } from './handleOAuthResponse'; // codeVerifier is required. May pass either an authorizationCode or interactionCode
|
|
20
|
-
|
|
21
|
-
export function exchangeCodeForTokens(sdk, tokenParams, urls) {
|
|
22
|
-
urls = urls || getOAuthUrls(sdk, tokenParams); // build params using defaults + options
|
|
23
|
-
|
|
24
|
-
tokenParams = Object.assign({}, getDefaultTokenParams(sdk), clone(tokenParams));
|
|
25
|
-
var {
|
|
26
|
-
authorizationCode,
|
|
27
|
-
interactionCode,
|
|
28
|
-
codeVerifier,
|
|
29
|
-
clientId,
|
|
30
|
-
redirectUri,
|
|
31
|
-
scopes,
|
|
32
|
-
ignoreSignature,
|
|
33
|
-
state
|
|
34
|
-
} = tokenParams;
|
|
35
|
-
var getTokenOptions = {
|
|
36
|
-
clientId,
|
|
37
|
-
redirectUri,
|
|
38
|
-
authorizationCode,
|
|
39
|
-
interactionCode,
|
|
40
|
-
codeVerifier
|
|
41
|
-
};
|
|
42
|
-
return postToTokenEndpoint(sdk, getTokenOptions, urls).then(response => {
|
|
43
|
-
// `handleOAuthResponse` hanadles responses from both `/authorize` and `/token` endpoints
|
|
44
|
-
// Here we modify the response from `/token` so that it more closely matches a response from `/authorize`
|
|
45
|
-
// `responseType` is used to validate that the expected tokens were returned
|
|
46
|
-
var responseType = ['token']; // an accessToken will always be returned
|
|
47
|
-
|
|
48
|
-
if (scopes.indexOf('openid') !== -1) {
|
|
49
|
-
responseType.push('id_token'); // an idToken will be returned if "openid" is in the scopes
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var handleResponseOptions = {
|
|
53
|
-
clientId,
|
|
54
|
-
redirectUri,
|
|
55
|
-
scopes,
|
|
56
|
-
responseType,
|
|
57
|
-
ignoreSignature
|
|
58
|
-
};
|
|
59
|
-
return handleOAuthResponse(sdk, handleResponseOptions, response, urls).then(response => {
|
|
60
|
-
// For compatibility, "code" is returned in the TokenResponse. OKTA-326091
|
|
61
|
-
response.code = authorizationCode;
|
|
62
|
-
response.state = state;
|
|
63
|
-
return response;
|
|
64
|
-
});
|
|
65
|
-
}).finally(() => {
|
|
66
|
-
sdk.transactionManager.clear();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=exchangeCodeForTokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/oidc/exchangeCodeForTokens.ts"],"names":["getOAuthUrls","getDefaultTokenParams","clone","postToTokenEndpoint","handleOAuthResponse","exchangeCodeForTokens","sdk","tokenParams","urls","Object","assign","authorizationCode","interactionCode","codeVerifier","clientId","redirectUri","scopes","ignoreSignature","state","getTokenOptions","then","response","responseType","indexOf","push","handleResponseOptions","code","finally","transactionManager","clear"],"mappings":"AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,SAA7B;AAEA,SAASC,qBAAT,QAAsC,QAAtC;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,mBAAT,QAAoC,mBAApC;AACA,SAASC,mBAAT,QAAoC,uBAApC,C,CAEA;;AACA,OAAO,SAASC,qBAAT,CAA+BC,GAA/B,EAA8CC,WAA9C,EAAwEC,IAAxE,EAAmH;AACxHA,EAAAA,IAAI,GAAGA,IAAI,IAAIR,YAAY,CAACM,GAAD,EAAMC,WAAN,CAA3B,CADwH,CAExH;;AACAA,EAAAA,WAAW,GAAGE,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBT,qBAAqB,CAACK,GAAD,CAAvC,EAA8CJ,KAAK,CAACK,WAAD,CAAnD,CAAd;AAEA,MAAM;AACJI,IAAAA,iBADI;AAEJC,IAAAA,eAFI;AAGJC,IAAAA,YAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,WALI;AAMJC,IAAAA,MANI;AAOJC,IAAAA,eAPI;AAQJC,IAAAA;AARI,MASFX,WATJ;AAWA,MAAIY,eAAe,GAAG;AACpBL,IAAAA,QADoB;AAEpBC,IAAAA,WAFoB;AAGpBJ,IAAAA,iBAHoB;AAIpBC,IAAAA,eAJoB;AAKpBC,IAAAA;AALoB,GAAtB;AAQA,SAAOV,mBAAmB,CAACG,GAAD,EAAMa,eAAN,EAAuBX,IAAvB,CAAnB,CACJY,IADI,CACEC,QAAD,IAA6B;AAEjC;AACA;AACA;AACA,QAAMC,YAAY,GAAG,CAAC,OAAD,CAArB,CALiC,CAKD;;AAChC,QAAIN,MAAM,CAACO,OAAP,CAAe,QAAf,MAA6B,CAAC,CAAlC,EAAqC;AACnCD,MAAAA,YAAY,CAACE,IAAb,CAAkB,UAAlB,EADmC,CACJ;AAChC;;AACD,QAAMC,qBAAkC,GAAG;AACzCX,MAAAA,QADyC;AAEzCC,MAAAA,WAFyC;AAGzCC,MAAAA,MAHyC;AAIzCM,MAAAA,YAJyC;AAKzCL,MAAAA;AALyC,KAA3C;AAOA,WAAOb,mBAAmB,CAACE,GAAD,EAAMmB,qBAAN,EAA6BJ,QAA7B,EAAuCb,IAAvC,CAAnB,CACJY,IADI,CACEC,QAAD,IAA6B;AACjC;AACAA,MAAAA,QAAQ,CAACK,IAAT,GAAgBf,iBAAhB;AACAU,MAAAA,QAAQ,CAACH,KAAT,GAAiBA,KAAjB;AACA,aAAOG,QAAP;AACD,KANI,CAAP;AAOD,GAxBI,EAyBJM,OAzBI,CAyBI,MAAM;AACbrB,IAAAA,GAAG,CAACsB,kBAAJ,CAAuBC,KAAvB;AACD,GA3BI,CAAP;AA4BD","sourcesContent":["/* eslint-disable max-len */\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 { getOAuthUrls } from '../oidc';\nimport { CustomUrls, OAuthResponse, OktaAuth, TokenParams, TokenResponse } from '../types';\nimport { getDefaultTokenParams } from './util';\nimport { clone } from '../util';\nimport { postToTokenEndpoint } from './endpoints/token';\nimport { handleOAuthResponse } from './handleOAuthResponse';\n\n// codeVerifier is required. May pass either an authorizationCode or interactionCode\nexport function exchangeCodeForTokens(sdk: OktaAuth, tokenParams: TokenParams, urls?: CustomUrls): Promise<TokenResponse> {\n urls = urls || getOAuthUrls(sdk, tokenParams);\n // build params using defaults + options\n tokenParams = Object.assign({}, getDefaultTokenParams(sdk), clone(tokenParams));\n\n const {\n authorizationCode,\n interactionCode,\n codeVerifier,\n clientId,\n redirectUri,\n scopes,\n ignoreSignature,\n state\n } = tokenParams;\n\n var getTokenOptions = {\n clientId,\n redirectUri,\n authorizationCode,\n interactionCode,\n codeVerifier,\n };\n\n return postToTokenEndpoint(sdk, getTokenOptions, urls)\n .then((response: OAuthResponse) => {\n\n // `handleOAuthResponse` hanadles responses from both `/authorize` and `/token` endpoints\n // Here we modify the response from `/token` so that it more closely matches a response from `/authorize`\n // `responseType` is used to validate that the expected tokens were returned\n const responseType = ['token']; // an accessToken will always be returned\n if (scopes.indexOf('openid') !== -1) {\n responseType.push('id_token'); // an idToken will be returned if \"openid\" is in the scopes\n }\n const handleResponseOptions: TokenParams = {\n clientId,\n redirectUri,\n scopes,\n responseType,\n ignoreSignature,\n };\n return handleOAuthResponse(sdk, handleResponseOptions, response, urls)\n .then((response: TokenResponse) => {\n // For compatibility, \"code\" is returned in the TokenResponse. OKTA-326091\n response.code = authorizationCode;\n response.state = state;\n return response;\n });\n })\n .finally(() => {\n sdk.transactionManager.clear();\n });\n}"],"file":"exchangeCodeForTokens.js"}
|
package/esm/oidc/getToken.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
|
|
3
|
-
/* eslint-disable complexity, max-statements */
|
|
4
|
-
|
|
5
|
-
/*!
|
|
6
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
7
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
8
|
-
*
|
|
9
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
*
|
|
14
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
import { getOAuthUrls, loadFrame } from './util';
|
|
18
|
-
import AuthSdkError from '../errors/AuthSdkError';
|
|
19
|
-
import { prepareTokenParams } from './util/prepareTokenParams';
|
|
20
|
-
import { buildAuthorizeParams } from './endpoints/authorize';
|
|
21
|
-
import { addPostMessageListener } from './util';
|
|
22
|
-
import { handleOAuthResponse } from './handleOAuthResponse';
|
|
23
|
-
/*
|
|
24
|
-
* Retrieve an idToken from an Okta or a third party idp
|
|
25
|
-
*
|
|
26
|
-
* Two main flows:
|
|
27
|
-
*
|
|
28
|
-
* 1) Exchange a sessionToken for a token
|
|
29
|
-
*
|
|
30
|
-
* Required:
|
|
31
|
-
* clientId: passed via the OktaAuth constructor or into getToken
|
|
32
|
-
* sessionToken: 'yourtoken'
|
|
33
|
-
*
|
|
34
|
-
* Optional:
|
|
35
|
-
* redirectUri: defaults to window.location.href
|
|
36
|
-
* scopes: defaults to ['openid', 'email']
|
|
37
|
-
*
|
|
38
|
-
* Forced:
|
|
39
|
-
* prompt: 'none'
|
|
40
|
-
* responseMode: 'okta_post_message'
|
|
41
|
-
* display: undefined
|
|
42
|
-
*
|
|
43
|
-
* 2) Get a token from an idp
|
|
44
|
-
*
|
|
45
|
-
* Required:
|
|
46
|
-
* clientId: passed via the OktaAuth constructor or into getToken
|
|
47
|
-
*
|
|
48
|
-
* Optional:
|
|
49
|
-
* redirectUri: defaults to window.location.href
|
|
50
|
-
* scopes: defaults to ['openid', 'email']
|
|
51
|
-
* idp: defaults to Okta as an idp
|
|
52
|
-
* prompt: no default. Pass 'none' to throw an error if user is not signed in
|
|
53
|
-
*
|
|
54
|
-
* Forced:
|
|
55
|
-
* display: 'popup'
|
|
56
|
-
*
|
|
57
|
-
* Only common optional params shown. Any OAuth parameters not explicitly forced are available to override
|
|
58
|
-
*
|
|
59
|
-
* @param {Object} oauthOptions
|
|
60
|
-
* @param {String} [oauthOptions.clientId] ID of this client
|
|
61
|
-
* @param {String} [oauthOptions.redirectUri] URI that the iframe or popup will go to once authenticated
|
|
62
|
-
* @param {String[]} [oauthOptions.scopes] OAuth 2.0 scopes to request (openid must be specified)
|
|
63
|
-
* @param {String} [oauthOptions.idp] ID of an external IdP to use for user authentication
|
|
64
|
-
* @param {String} [oauthOptions.sessionToken] Bootstrap Session Token returned by the Okta Authentication API
|
|
65
|
-
* @param {String} [oauthOptions.prompt] Determines whether the Okta login will be displayed on failure.
|
|
66
|
-
* Use 'none' to prevent this behavior
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} options
|
|
69
|
-
* @param {Integer} [options.timeout] Time in ms before the flow is automatically terminated. Defaults to 120000
|
|
70
|
-
* @param {String} [options.popupTitle] Title dispayed in the popup.
|
|
71
|
-
* Defaults to 'External Identity Provider User Authentication'
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
export function getToken(sdk, options) {
|
|
75
|
-
if (arguments.length > 2) {
|
|
76
|
-
return Promise.reject(new AuthSdkError('As of version 3.0, "getToken" takes only a single set of options'));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
options = options || {}; // window object cannot be serialized, save for later use
|
|
80
|
-
// TODO: move popup related params into a separate options object
|
|
81
|
-
|
|
82
|
-
var popupWindow = options.popupWindow;
|
|
83
|
-
options.popupWindow = undefined;
|
|
84
|
-
return prepareTokenParams(sdk, options).then(function (tokenParams) {
|
|
85
|
-
// Start overriding any options that don't make sense
|
|
86
|
-
var sessionTokenOverrides = {
|
|
87
|
-
prompt: 'none',
|
|
88
|
-
responseMode: 'okta_post_message',
|
|
89
|
-
display: null
|
|
90
|
-
};
|
|
91
|
-
var idpOverrides = {
|
|
92
|
-
display: 'popup'
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
if (options.sessionToken) {
|
|
96
|
-
Object.assign(tokenParams, sessionTokenOverrides);
|
|
97
|
-
} else if (options.idp) {
|
|
98
|
-
Object.assign(tokenParams, idpOverrides);
|
|
99
|
-
} // Use the query params to build the authorize url
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var requestUrl, endpoint, urls; // Get authorizeUrl and issuer
|
|
103
|
-
|
|
104
|
-
urls = getOAuthUrls(sdk, tokenParams);
|
|
105
|
-
endpoint = options.codeVerifier ? urls.tokenUrl : urls.authorizeUrl;
|
|
106
|
-
requestUrl = endpoint + buildAuthorizeParams(tokenParams); // Determine the flow type
|
|
107
|
-
|
|
108
|
-
var flowType;
|
|
109
|
-
|
|
110
|
-
if (tokenParams.sessionToken || tokenParams.display === null) {
|
|
111
|
-
flowType = 'IFRAME';
|
|
112
|
-
} else if (tokenParams.display === 'popup') {
|
|
113
|
-
flowType = 'POPUP';
|
|
114
|
-
} else {
|
|
115
|
-
flowType = 'IMPLICIT';
|
|
116
|
-
} // Execute the flow type
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
switch (flowType) {
|
|
120
|
-
case 'IFRAME':
|
|
121
|
-
var iframePromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);
|
|
122
|
-
var iframeEl = loadFrame(requestUrl);
|
|
123
|
-
return iframePromise.then(function (res) {
|
|
124
|
-
return handleOAuthResponse(sdk, tokenParams, res, urls);
|
|
125
|
-
}).finally(function () {
|
|
126
|
-
if (document.body.contains(iframeEl)) {
|
|
127
|
-
iframeEl.parentElement.removeChild(iframeEl);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
case 'POPUP':
|
|
132
|
-
var oauthPromise; // resolves with OAuth response
|
|
133
|
-
// Add listener on postMessage before window creation, so
|
|
134
|
-
// postMessage isn't triggered before we're listening
|
|
135
|
-
|
|
136
|
-
if (tokenParams.responseMode === 'okta_post_message') {
|
|
137
|
-
if (!sdk.features.isPopupPostMessageSupported()) {
|
|
138
|
-
throw new AuthSdkError('This browser doesn\'t have full postMessage support');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
oauthPromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);
|
|
142
|
-
} // Redirect for authorization
|
|
143
|
-
// popupWindown can be null when popup is blocked
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (popupWindow) {
|
|
147
|
-
popupWindow.location.assign(requestUrl);
|
|
148
|
-
} // The popup may be closed without receiving an OAuth response. Setup a poller to monitor the window.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
var popupPromise = new Promise(function (resolve, reject) {
|
|
152
|
-
var closePoller = setInterval(function () {
|
|
153
|
-
if (!popupWindow || popupWindow.closed) {
|
|
154
|
-
clearInterval(closePoller);
|
|
155
|
-
reject(new AuthSdkError('Unable to parse OAuth flow response'));
|
|
156
|
-
}
|
|
157
|
-
}, 100); // Proxy the OAuth promise results
|
|
158
|
-
|
|
159
|
-
oauthPromise.then(function (res) {
|
|
160
|
-
clearInterval(closePoller);
|
|
161
|
-
resolve(res);
|
|
162
|
-
}).catch(function (err) {
|
|
163
|
-
clearInterval(closePoller);
|
|
164
|
-
reject(err);
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
return popupPromise.then(function (res) {
|
|
168
|
-
return handleOAuthResponse(sdk, tokenParams, res, urls);
|
|
169
|
-
}).finally(function () {
|
|
170
|
-
if (popupWindow && !popupWindow.closed) {
|
|
171
|
-
popupWindow.close();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
default:
|
|
176
|
-
throw new AuthSdkError('The full page redirect flow is not supported');
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=getToken.js.map
|
package/esm/oidc/getToken.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/oidc/getToken.ts"],"names":["getOAuthUrls","loadFrame","AuthSdkError","prepareTokenParams","buildAuthorizeParams","addPostMessageListener","handleOAuthResponse","getToken","sdk","options","arguments","length","Promise","reject","popupWindow","undefined","then","tokenParams","sessionTokenOverrides","prompt","responseMode","display","idpOverrides","sessionToken","Object","assign","idp","requestUrl","endpoint","urls","codeVerifier","tokenUrl","authorizeUrl","flowType","iframePromise","timeout","state","iframeEl","res","finally","document","body","contains","parentElement","removeChild","oauthPromise","features","isPopupPostMessageSupported","location","popupPromise","resolve","closePoller","setInterval","closed","clearInterval","catch","err","close"],"mappings":"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","sourcesContent":["\n/* global document */\n/* eslint-disable complexity, max-statements */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport {\n getOAuthUrls,\n loadFrame,\n} from './util';\n\nimport AuthSdkError from '../errors/AuthSdkError';\n\nimport {\n OktaAuth,\n TokenParams,\n PopupParams,\n} from '../types';\n\nimport { prepareTokenParams } from './util/prepareTokenParams';\nimport { buildAuthorizeParams } from './endpoints/authorize';\nimport { addPostMessageListener } from './util';\nimport { handleOAuthResponse } from './handleOAuthResponse';\n/*\n * Retrieve an idToken from an Okta or a third party idp\n *\n * Two main flows:\n *\n * 1) Exchange a sessionToken for a token\n *\n * Required:\n * clientId: passed via the OktaAuth constructor or into getToken\n * sessionToken: 'yourtoken'\n *\n * Optional:\n * redirectUri: defaults to window.location.href\n * scopes: defaults to ['openid', 'email']\n *\n * Forced:\n * prompt: 'none'\n * responseMode: 'okta_post_message'\n * display: undefined\n *\n * 2) Get a token from an idp\n *\n * Required:\n * clientId: passed via the OktaAuth constructor or into getToken\n *\n * Optional:\n * redirectUri: defaults to window.location.href\n * scopes: defaults to ['openid', 'email']\n * idp: defaults to Okta as an idp\n * prompt: no default. Pass 'none' to throw an error if user is not signed in\n *\n * Forced:\n * display: 'popup'\n *\n * Only common optional params shown. Any OAuth parameters not explicitly forced are available to override\n *\n * @param {Object} oauthOptions\n * @param {String} [oauthOptions.clientId] ID of this client\n * @param {String} [oauthOptions.redirectUri] URI that the iframe or popup will go to once authenticated\n * @param {String[]} [oauthOptions.scopes] OAuth 2.0 scopes to request (openid must be specified)\n * @param {String} [oauthOptions.idp] ID of an external IdP to use for user authentication\n * @param {String} [oauthOptions.sessionToken] Bootstrap Session Token returned by the Okta Authentication API\n * @param {String} [oauthOptions.prompt] Determines whether the Okta login will be displayed on failure.\n * Use 'none' to prevent this behavior\n *\n * @param {Object} options\n * @param {Integer} [options.timeout] Time in ms before the flow is automatically terminated. Defaults to 120000\n * @param {String} [options.popupTitle] Title dispayed in the popup.\n * Defaults to 'External Identity Provider User Authentication'\n */\nexport function getToken(sdk: OktaAuth, options: TokenParams & PopupParams) {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getToken\" takes only a single set of options'));\n }\n\n options = options || {};\n\n // window object cannot be serialized, save for later use\n // TODO: move popup related params into a separate options object\n const popupWindow = options.popupWindow;\n options.popupWindow = undefined;\n\n return prepareTokenParams(sdk, options)\n .then(function (tokenParams: TokenParams) {\n\n // Start overriding any options that don't make sense\n var sessionTokenOverrides = {\n prompt: 'none',\n responseMode: 'okta_post_message',\n display: null\n };\n\n var idpOverrides = {\n display: 'popup'\n };\n\n if (options.sessionToken) {\n Object.assign(tokenParams, sessionTokenOverrides);\n } else if (options.idp) {\n Object.assign(tokenParams, idpOverrides);\n }\n\n // Use the query params to build the authorize url\n var requestUrl,\n endpoint,\n urls;\n\n // Get authorizeUrl and issuer\n urls = getOAuthUrls(sdk, tokenParams);\n endpoint = options.codeVerifier ? urls.tokenUrl : urls.authorizeUrl;\n requestUrl = endpoint + buildAuthorizeParams(tokenParams);\n\n // Determine the flow type\n var flowType;\n if (tokenParams.sessionToken || tokenParams.display === null) {\n flowType = 'IFRAME';\n } else if (tokenParams.display === 'popup') {\n flowType = 'POPUP';\n } else {\n flowType = 'IMPLICIT';\n }\n\n // Execute the flow type\n switch (flowType) {\n case 'IFRAME':\n var iframePromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);\n var iframeEl = loadFrame(requestUrl);\n return iframePromise\n .then(function (res) {\n return handleOAuthResponse(sdk, tokenParams, res, urls);\n })\n .finally(function () {\n if (document.body.contains(iframeEl)) {\n iframeEl.parentElement.removeChild(iframeEl);\n }\n });\n\n case 'POPUP':\n var oauthPromise; // resolves with OAuth response\n\n // Add listener on postMessage before window creation, so\n // postMessage isn't triggered before we're listening\n if (tokenParams.responseMode === 'okta_post_message') {\n if (!sdk.features.isPopupPostMessageSupported()) {\n throw new AuthSdkError('This browser doesn\\'t have full postMessage support');\n }\n oauthPromise = addPostMessageListener(sdk, options.timeout, tokenParams.state);\n }\n\n // Redirect for authorization\n // popupWindown can be null when popup is blocked\n if (popupWindow) { \n popupWindow.location.assign(requestUrl);\n }\n\n // The popup may be closed without receiving an OAuth response. Setup a poller to monitor the window.\n var popupPromise = new Promise(function (resolve, reject) {\n var closePoller = setInterval(function () {\n if (!popupWindow || popupWindow.closed) {\n clearInterval(closePoller);\n reject(new AuthSdkError('Unable to parse OAuth flow response'));\n }\n }, 100);\n\n // Proxy the OAuth promise results\n oauthPromise\n .then(function (res) {\n clearInterval(closePoller);\n resolve(res);\n })\n .catch(function (err) {\n clearInterval(closePoller);\n reject(err);\n });\n });\n\n return popupPromise\n .then(function (res) {\n return handleOAuthResponse(sdk, tokenParams, res, urls);\n })\n .finally(function () {\n if (popupWindow && !popupWindow.closed) {\n popupWindow.close();\n }\n });\n\n default:\n throw new AuthSdkError('The full page redirect flow is not supported');\n }\n });\n}"],"file":"getToken.js"}
|
package/esm/oidc/getUserInfo.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
|
|
5
|
-
/*!
|
|
6
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
7
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
8
|
-
*
|
|
9
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
*
|
|
14
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
import { isFunction } from '../util';
|
|
18
|
-
import { AuthSdkError, OAuthError } from '../errors';
|
|
19
|
-
import { httpRequest } from '../http';
|
|
20
|
-
import { isAccessToken, isIDToken } from '../types';
|
|
21
|
-
export function getUserInfo(_x, _x2, _x3) {
|
|
22
|
-
return _getUserInfo.apply(this, arguments);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _getUserInfo() {
|
|
26
|
-
_getUserInfo = _asyncToGenerator(function* (sdk, accessTokenObject, idTokenObject) {
|
|
27
|
-
// If token objects were not passed, attempt to read from the TokenManager
|
|
28
|
-
if (!accessTokenObject) {
|
|
29
|
-
accessTokenObject = (yield sdk.tokenManager.getTokens()).accessToken;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!idTokenObject) {
|
|
33
|
-
idTokenObject = (yield sdk.tokenManager.getTokens()).idToken;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!accessTokenObject || !isAccessToken(accessTokenObject)) {
|
|
37
|
-
return Promise.reject(new AuthSdkError('getUserInfo requires an access token object'));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!idTokenObject || !isIDToken(idTokenObject)) {
|
|
41
|
-
return Promise.reject(new AuthSdkError('getUserInfo requires an ID token object'));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return httpRequest(sdk, {
|
|
45
|
-
url: accessTokenObject.userinfoUrl,
|
|
46
|
-
method: 'GET',
|
|
47
|
-
accessToken: accessTokenObject.accessToken
|
|
48
|
-
}).then(userInfo => {
|
|
49
|
-
// Only return the userinfo response if subjects match to mitigate token substitution attacks
|
|
50
|
-
if (userInfo.sub === idTokenObject.claims.sub) {
|
|
51
|
-
return userInfo;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return Promise.reject(new AuthSdkError('getUserInfo request was rejected due to token mismatch'));
|
|
55
|
-
}).catch(function (err) {
|
|
56
|
-
if (err.xhr && (err.xhr.status === 401 || err.xhr.status === 403)) {
|
|
57
|
-
var authenticateHeader;
|
|
58
|
-
|
|
59
|
-
if (err.xhr.headers && isFunction(err.xhr.headers.get) && err.xhr.headers.get('WWW-Authenticate')) {
|
|
60
|
-
authenticateHeader = err.xhr.headers.get('WWW-Authenticate');
|
|
61
|
-
} else if (isFunction(err.xhr.getResponseHeader)) {
|
|
62
|
-
authenticateHeader = err.xhr.getResponseHeader('WWW-Authenticate');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (authenticateHeader) {
|
|
66
|
-
var errorMatches = authenticateHeader.match(/error="(.*?)"/) || [];
|
|
67
|
-
var errorDescriptionMatches = authenticateHeader.match(/error_description="(.*?)"/) || [];
|
|
68
|
-
var error = errorMatches[1];
|
|
69
|
-
var errorDescription = errorDescriptionMatches[1];
|
|
70
|
-
|
|
71
|
-
if (error && errorDescription) {
|
|
72
|
-
err = new OAuthError(error, errorDescription);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
throw err;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
return _getUserInfo.apply(this, arguments);
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=getUserInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/oidc/getUserInfo.ts"],"names":["isFunction","AuthSdkError","OAuthError","httpRequest","isAccessToken","isIDToken","getUserInfo","sdk","accessTokenObject","idTokenObject","tokenManager","getTokens","accessToken","idToken","Promise","reject","url","userinfoUrl","method","then","userInfo","sub","claims","catch","err","xhr","status","authenticateHeader","headers","get","getResponseHeader","errorMatches","match","errorDescriptionMatches","error","errorDescription"],"mappings":"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","sourcesContent":["/* eslint-disable complexity */\n/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport { isFunction } from '../util';\nimport { AuthSdkError, OAuthError } from '../errors';\nimport { httpRequest } from '../http';\nimport { AccessToken, IDToken, UserClaims, isAccessToken, isIDToken } from '../types';\n\nexport async function getUserInfo(sdk, accessTokenObject: AccessToken, idTokenObject: IDToken): Promise<UserClaims> {\n // If token objects were not passed, attempt to read from the TokenManager\n if (!accessTokenObject) {\n accessTokenObject = (await sdk.tokenManager.getTokens()).accessToken as AccessToken;\n }\n if (!idTokenObject) {\n idTokenObject = (await sdk.tokenManager.getTokens()).idToken as IDToken;\n }\n\n if (!accessTokenObject || !isAccessToken(accessTokenObject)) {\n return Promise.reject(new AuthSdkError('getUserInfo requires an access token object'));\n }\n\n if (!idTokenObject || !isIDToken(idTokenObject)) {\n return Promise.reject(new AuthSdkError('getUserInfo requires an ID token object'));\n }\n\n return httpRequest(sdk, {\n url: accessTokenObject.userinfoUrl,\n method: 'GET',\n accessToken: accessTokenObject.accessToken\n })\n .then(userInfo => {\n // Only return the userinfo response if subjects match to mitigate token substitution attacks\n if (userInfo.sub === idTokenObject.claims.sub) {\n return userInfo;\n }\n return Promise.reject(new AuthSdkError('getUserInfo request was rejected due to token mismatch'));\n })\n .catch(function (err) {\n if (err.xhr && (err.xhr.status === 401 || err.xhr.status === 403)) {\n var authenticateHeader;\n if (err.xhr.headers && isFunction(err.xhr.headers.get) && err.xhr.headers.get('WWW-Authenticate')) {\n authenticateHeader = err.xhr.headers.get('WWW-Authenticate');\n } else if (isFunction(err.xhr.getResponseHeader)) {\n authenticateHeader = err.xhr.getResponseHeader('WWW-Authenticate');\n }\n if (authenticateHeader) {\n var errorMatches = authenticateHeader.match(/error=\"(.*?)\"/) || [];\n var errorDescriptionMatches = authenticateHeader.match(/error_description=\"(.*?)\"/) || [];\n var error = errorMatches[1];\n var errorDescription = errorDescriptionMatches[1];\n if (error && errorDescription) {\n err = new OAuthError(error, errorDescription);\n }\n }\n }\n throw err;\n });\n}\n"],"file":"getUserInfo.js"}
|
package/esm/oidc/getWithPopup.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
-
*
|
|
10
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
import { AuthSdkError } from '../errors';
|
|
14
|
-
import { clone } from '../util';
|
|
15
|
-
import { getToken } from './getToken';
|
|
16
|
-
import { loadPopup } from './util';
|
|
17
|
-
export function getWithPopup(sdk, options) {
|
|
18
|
-
if (arguments.length > 2) {
|
|
19
|
-
return Promise.reject(new AuthSdkError('As of version 3.0, "getWithPopup" takes only a single set of options'));
|
|
20
|
-
} // some browsers (safari, firefox) block popup if it's initialed from an async process
|
|
21
|
-
// here we create the popup window immediately after user interaction
|
|
22
|
-
// then redirect to the /authorize endpoint when the requestUrl is available
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var popupWindow = loadPopup('/', options);
|
|
26
|
-
options = clone(options) || {};
|
|
27
|
-
Object.assign(options, {
|
|
28
|
-
display: 'popup',
|
|
29
|
-
responseMode: 'okta_post_message',
|
|
30
|
-
popupWindow
|
|
31
|
-
});
|
|
32
|
-
return getToken(sdk, options);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=getWithPopup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/oidc/getWithPopup.ts"],"names":["AuthSdkError","clone","getToken","loadPopup","getWithPopup","sdk","options","arguments","length","Promise","reject","popupWindow","Object","assign","display","responseMode"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,WAA7B;AAEA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,QAAT,QAAyB,YAAzB;AACA,SAASC,SAAT,QAA0B,QAA1B;AAEA,OAAO,SAASC,YAAT,CAAsBC,GAAtB,EAAqCC,OAArC,EAAmF;AACxF,MAAIC,SAAS,CAACC,MAAV,GAAmB,CAAvB,EAA0B;AACxB,WAAOC,OAAO,CAACC,MAAR,CAAe,IAAIV,YAAJ,CAAiB,sEAAjB,CAAf,CAAP;AACD,GAHuF,CAKxF;AACA;AACA;;;AACA,MAAMW,WAAW,GAAGR,SAAS,CAAC,GAAD,EAAMG,OAAN,CAA7B;AACAA,EAAAA,OAAO,GAAGL,KAAK,CAACK,OAAD,CAAL,IAAkB,EAA5B;AACAM,EAAAA,MAAM,CAACC,MAAP,CAAcP,OAAd,EAAuB;AACrBQ,IAAAA,OAAO,EAAE,OADY;AAErBC,IAAAA,YAAY,EAAE,mBAFO;AAGrBJ,IAAAA;AAHqB,GAAvB;AAKA,SAAOT,QAAQ,CAACG,GAAD,EAAMC,OAAN,CAAf;AACD","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\nimport { AuthSdkError } from '../errors';\nimport { OktaAuth, TokenParams, TokenResponse } from '../types';\nimport { clone } from '../util';\nimport { getToken } from './getToken';\nimport { loadPopup } from './util';\n\nexport function getWithPopup(sdk: OktaAuth, options: TokenParams): Promise<TokenResponse> {\n if (arguments.length > 2) {\n return Promise.reject(new AuthSdkError('As of version 3.0, \"getWithPopup\" takes only a single set of options'));\n }\n\n // some browsers (safari, firefox) block popup if it's initialed from an async process\n // here we create the popup window immediately after user interaction\n // then redirect to the /authorize endpoint when the requestUrl is available\n const popupWindow = loadPopup('/', options);\n options = clone(options) || {};\n Object.assign(options, {\n display: 'popup',\n responseMode: 'okta_post_message',\n popupWindow\n });\n return getToken(sdk, options);\n}\n"],"file":"getWithPopup.js"}
|