@okta/okta-auth-js 7.0.0 → 7.1.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.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/cjs/authn/AuthnTransactionImpl.js +6 -8
- package/cjs/authn/AuthnTransactionImpl.js.map +1 -1
- package/cjs/authn/api.js +3 -18
- package/cjs/authn/api.js.map +1 -1
- package/cjs/authn/factory.js +1 -7
- package/cjs/authn/factory.js.map +1 -1
- package/cjs/authn/index.js +0 -5
- package/cjs/authn/index.js.map +1 -1
- package/cjs/authn/mixin.js +14 -22
- package/cjs/authn/mixin.js.map +1 -1
- package/cjs/authn/util/flattenEmbedded.js +5 -12
- package/cjs/authn/util/flattenEmbedded.js.map +1 -1
- package/cjs/authn/util/link2fn.js +0 -22
- package/cjs/authn/util/link2fn.js.map +1 -1
- package/cjs/authn/util/links2fns.js +0 -12
- package/cjs/authn/util/links2fns.js.map +1 -1
- package/cjs/authn/util/poll.js +9 -27
- package/cjs/authn/util/poll.js.map +1 -1
- package/cjs/authn/util/stateToken.js +3 -4
- package/cjs/authn/util/stateToken.js.map +1 -1
- package/cjs/base/factory.js +6 -14
- package/cjs/base/factory.js.map +1 -1
- package/cjs/base/index.js +0 -5
- package/cjs/base/index.js.map +1 -1
- package/cjs/base/options.js +1 -2
- package/cjs/base/options.js.map +1 -1
- package/cjs/browser/browserStorage.js +15 -43
- package/cjs/browser/browserStorage.js.map +1 -1
- package/cjs/browser/fingerprint.js +3 -15
- package/cjs/browser/fingerprint.js.map +1 -1
- package/cjs/clock.js +5 -7
- package/cjs/clock.js.map +1 -1
- package/cjs/constants.js +4 -3
- package/cjs/constants.js.map +1 -1
- package/cjs/core/AuthStateManager.js +24 -48
- package/cjs/core/AuthStateManager.js.map +1 -1
- package/cjs/core/ServiceManager/browser.js +13 -33
- package/cjs/core/ServiceManager/browser.js.map +1 -1
- package/cjs/core/ServiceManager/index.js +0 -1
- package/cjs/core/ServiceManager/index.js.map +1 -1
- package/cjs/core/ServiceManager/node.js +3 -9
- package/cjs/core/ServiceManager/node.js.map +1 -1
- package/cjs/core/factory.js +0 -7
- package/cjs/core/factory.js.map +1 -1
- package/cjs/core/index.js +0 -13
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/mixin.js +16 -20
- package/cjs/core/mixin.js.map +1 -1
- package/cjs/core/options.js +1 -3
- package/cjs/core/options.js.map +1 -1
- package/cjs/core/storage.js +0 -2
- package/cjs/core/storage.js.map +1 -1
- package/cjs/core/types/index.js +0 -5
- package/cjs/core/types/index.js.map +1 -1
- package/cjs/crypto/base64.js +9 -22
- package/cjs/crypto/base64.js.map +1 -1
- package/cjs/crypto/browser.js +0 -4
- package/cjs/crypto/browser.js.map +1 -1
- package/cjs/crypto/index.js +0 -9
- package/cjs/crypto/index.js.map +1 -1
- package/cjs/crypto/node.js +0 -13
- package/cjs/crypto/node.js.map +1 -1
- package/cjs/crypto/oidcHash.js +1 -4
- package/cjs/crypto/oidcHash.js.map +1 -1
- package/cjs/crypto/verifyToken.js +6 -7
- package/cjs/crypto/verifyToken.js.map +1 -1
- package/cjs/crypto/webcrypto.js +0 -1
- package/cjs/crypto/webcrypto.js.map +1 -1
- package/cjs/errors/AuthApiError.js +1 -7
- package/cjs/errors/AuthApiError.js.map +1 -1
- package/cjs/errors/AuthPollStopError.js +1 -5
- package/cjs/errors/AuthPollStopError.js.map +1 -1
- package/cjs/errors/AuthSdkError.js +1 -6
- package/cjs/errors/AuthSdkError.js.map +1 -1
- package/cjs/errors/CustomError.js +1 -4
- package/cjs/errors/CustomError.js.map +1 -1
- package/cjs/errors/OAuthError.js +4 -7
- package/cjs/errors/OAuthError.js.map +1 -1
- package/cjs/errors/index.js +1 -9
- package/cjs/errors/index.js.map +1 -1
- package/cjs/exports/authn.js +0 -9
- package/cjs/exports/authn.js.map +1 -1
- package/cjs/exports/cdn/authn.js +0 -2
- package/cjs/exports/cdn/authn.js.map +1 -1
- package/cjs/exports/cdn/core.js +0 -2
- package/cjs/exports/cdn/core.js.map +1 -1
- package/cjs/exports/cdn/default.js +0 -2
- package/cjs/exports/cdn/default.js.map +1 -1
- package/cjs/exports/cdn/idx.js +0 -2
- package/cjs/exports/cdn/idx.js.map +1 -1
- package/cjs/exports/cdn/myaccount.js +0 -2
- package/cjs/exports/cdn/myaccount.js.map +1 -1
- package/cjs/exports/common.js +0 -22
- package/cjs/exports/common.js.map +1 -1
- package/cjs/exports/core.js +0 -9
- package/cjs/exports/core.js.map +1 -1
- package/cjs/exports/default.js +2 -12
- package/cjs/exports/default.js.map +1 -1
- package/cjs/exports/idx.js +3 -7
- package/cjs/exports/idx.js.map +1 -1
- package/cjs/exports/myaccount.js +0 -9
- package/cjs/exports/myaccount.js.map +1 -1
- package/cjs/features.js +1 -18
- package/cjs/features.js.map +1 -1
- package/cjs/fetch/fetchRequest.js +6 -20
- package/cjs/fetch/fetchRequest.js.map +1 -1
- package/cjs/http/OktaUserAgent.js +3 -11
- package/cjs/http/OktaUserAgent.js.map +1 -1
- package/cjs/http/headers.js +1 -1
- package/cjs/http/headers.js.map +1 -1
- package/cjs/http/index.js +0 -11
- package/cjs/http/index.js.map +1 -1
- package/cjs/http/mixin.js +2 -10
- package/cjs/http/mixin.js.map +1 -1
- package/cjs/http/options.js +1 -5
- package/cjs/http/options.js.map +1 -1
- package/cjs/http/request.js +75 -57
- package/cjs/http/request.js.map +1 -1
- package/cjs/idx/IdxTransactionManager.js +2 -22
- package/cjs/idx/IdxTransactionManager.js.map +1 -1
- package/cjs/idx/authenticate.js +3 -5
- package/cjs/idx/authenticate.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js +2 -4
- package/cjs/idx/authenticator/Authenticator.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js +2 -10
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/OktaVerifyTotp.js +0 -6
- package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +0 -10
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js +1 -10
- package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +2 -10
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnEnrollment.js +0 -8
- package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnVerification.js +0 -8
- package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -1
- package/cjs/idx/authenticator/getAuthenticator.js +0 -15
- package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/index.js +0 -15
- package/cjs/idx/authenticator/index.js.map +1 -1
- package/cjs/idx/authenticator/util.js +8 -18
- package/cjs/idx/authenticator/util.js.map +1 -1
- package/cjs/idx/cancel.js +3 -4
- package/cjs/idx/cancel.js.map +1 -1
- package/cjs/idx/emailVerify.js +5 -13
- package/cjs/idx/emailVerify.js.map +1 -1
- package/cjs/idx/factory/OktaAuthIdx.js +0 -3
- package/cjs/idx/factory/OktaAuthIdx.js.map +1 -1
- package/cjs/idx/factory/api.js +1 -17
- package/cjs/idx/factory/api.js.map +1 -1
- package/cjs/idx/factory/index.js +0 -3
- package/cjs/idx/factory/index.js.map +1 -1
- package/cjs/idx/flow/AccountUnlockFlow.js +1 -2
- package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -1
- package/cjs/idx/flow/AuthenticationFlow.js +1 -2
- package/cjs/idx/flow/AuthenticationFlow.js.map +1 -1
- package/cjs/idx/flow/FlowSpecification.js +2 -13
- package/cjs/idx/flow/FlowSpecification.js.map +1 -1
- package/cjs/idx/flow/PasswordRecoveryFlow.js +1 -2
- package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -1
- package/cjs/idx/flow/RegistrationFlow.js +1 -2
- package/cjs/idx/flow/RegistrationFlow.js.map +1 -1
- package/cjs/idx/flow/index.js +0 -11
- package/cjs/idx/flow/index.js.map +1 -1
- package/cjs/idx/handleInteractionCodeRedirect.js +7 -12
- package/cjs/idx/handleInteractionCodeRedirect.js.map +1 -1
- package/cjs/idx/idxState/index.js +1 -11
- package/cjs/idx/idxState/index.js.map +1 -1
- package/cjs/idx/idxState/v1/actionParser.js +1 -12
- package/cjs/idx/idxState/v1/actionParser.js.map +1 -1
- package/cjs/idx/idxState/v1/generateIdxAction.js +10 -15
- package/cjs/idx/idxState/v1/generateIdxAction.js.map +1 -1
- package/cjs/idx/idxState/v1/idxResponseParser.js +7 -23
- package/cjs/idx/idxState/v1/idxResponseParser.js.map +1 -1
- package/cjs/idx/idxState/v1/makeIdxState.js +2 -10
- package/cjs/idx/idxState/v1/makeIdxState.js.map +1 -1
- package/cjs/idx/idxState/v1/parsers.js +0 -2
- package/cjs/idx/idxState/v1/parsers.js.map +1 -1
- package/cjs/idx/idxState/v1/remediationParser.js +2 -4
- package/cjs/idx/idxState/v1/remediationParser.js.map +1 -1
- package/cjs/idx/index.js +0 -26
- package/cjs/idx/index.js.map +1 -1
- package/cjs/idx/interact.js +18 -18
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/introspect.js +5 -14
- package/cjs/idx/introspect.js.map +1 -1
- package/cjs/idx/mixin.js +0 -9
- package/cjs/idx/mixin.js.map +1 -1
- package/cjs/idx/options.js +2 -3
- package/cjs/idx/options.js.map +1 -1
- package/cjs/idx/poll.js +1 -10
- package/cjs/idx/poll.js.map +1 -1
- package/cjs/idx/proceed.js +3 -9
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/recoverPassword.js +3 -4
- package/cjs/idx/recoverPassword.js.map +1 -1
- package/cjs/idx/register.js +5 -11
- package/cjs/idx/register.js.map +1 -1
- package/cjs/idx/remediate.js +24 -45
- package/cjs/idx/remediate.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +7 -16
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +7 -15
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +7 -22
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +38 -67
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +13 -30
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +5 -13
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengeAuthenticator.js +1 -5
- package/cjs/idx/remediators/ChallengeAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengePoll.js +1 -6
- package/cjs/idx/remediators/ChallengePoll.js.map +1 -1
- package/cjs/idx/remediators/EnrollAuthenticator.js +1 -5
- package/cjs/idx/remediators/EnrollAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/EnrollPoll.js +5 -12
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
- package/cjs/idx/remediators/EnrollProfile.js +8 -30
- package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/EnrollmentChannelData.js +5 -13
- package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
- package/cjs/idx/remediators/GenericRemediator/GenericRemediator.js +13 -19
- package/cjs/idx/remediators/GenericRemediator/GenericRemediator.js.map +1 -1
- package/cjs/idx/remediators/GenericRemediator/index.js +0 -1
- package/cjs/idx/remediators/GenericRemediator/index.js.map +1 -1
- package/cjs/idx/remediators/GenericRemediator/util.js +19 -31
- package/cjs/idx/remediators/GenericRemediator/util.js.map +1 -1
- package/cjs/idx/remediators/Identify.js +3 -12
- package/cjs/idx/remediators/Identify.js.map +1 -1
- package/cjs/idx/remediators/ReEnrollAuthenticator.js +3 -10
- package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/RedirectIdp.js +1 -7
- package/cjs/idx/remediators/RedirectIdp.js.map +1 -1
- package/cjs/idx/remediators/ResetAuthenticator.js +1 -5
- package/cjs/idx/remediators/ResetAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +3 -11
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +1 -5
- package/cjs/idx/remediators/SelectAuthenticatorEnroll.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +6 -15
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
- package/cjs/idx/remediators/SelectEnrollProfile.js +1 -6
- package/cjs/idx/remediators/SelectEnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/SelectEnrollmentChannel.js +5 -16
- package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
- package/cjs/idx/remediators/Skip.js +1 -6
- package/cjs/idx/remediators/Skip.js.map +1 -1
- package/cjs/idx/remediators/index.js +0 -39
- package/cjs/idx/remediators/index.js.map +1 -1
- package/cjs/idx/remediators/util.js +1 -7
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +39 -54
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/startTransaction.js +1 -2
- package/cjs/idx/startTransaction.js.map +1 -1
- package/cjs/idx/storage.js +3 -22
- package/cjs/idx/storage.js.map +1 -1
- package/cjs/idx/transactionMeta.js +24 -42
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/types/api.js +1 -9
- package/cjs/idx/types/api.js.map +1 -1
- package/cjs/idx/types/idx-js.js +3 -3
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/types/index.js +0 -7
- package/cjs/idx/types/index.js.map +1 -1
- package/cjs/idx/types/meta.js.map +1 -1
- package/cjs/idx/types/options.js.map +1 -1
- package/cjs/idx/unlockAccount.js +7 -11
- package/cjs/idx/unlockAccount.js.map +1 -1
- package/cjs/idx/util.js +24 -76
- package/cjs/idx/util.js.map +1 -1
- package/cjs/idx/webauthn.js +13 -18
- package/cjs/idx/webauthn.js.map +1 -1
- package/cjs/myaccount/api.js +0 -5
- package/cjs/myaccount/api.js.map +1 -1
- package/cjs/myaccount/emailApi.js +6 -21
- package/cjs/myaccount/emailApi.js.map +1 -1
- package/cjs/myaccount/factory.js +0 -3
- package/cjs/myaccount/factory.js.map +1 -1
- package/cjs/myaccount/index.js +0 -7
- package/cjs/myaccount/index.js.map +1 -1
- package/cjs/myaccount/mixin.js +0 -5
- package/cjs/myaccount/mixin.js.map +1 -1
- package/cjs/myaccount/phoneApi.js +5 -18
- package/cjs/myaccount/phoneApi.js.map +1 -1
- package/cjs/myaccount/profileApi.js +2 -9
- package/cjs/myaccount/profileApi.js.map +1 -1
- package/cjs/myaccount/request.js +12 -78
- package/cjs/myaccount/request.js.map +1 -1
- package/cjs/myaccount/transactions/Base.js +5 -7
- package/cjs/myaccount/transactions/Base.js.map +1 -1
- package/cjs/myaccount/transactions/EmailChallengeTransaction.js +5 -10
- package/cjs/myaccount/transactions/EmailChallengeTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/EmailStatusTransaction.js +2 -7
- package/cjs/myaccount/transactions/EmailStatusTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/EmailTransaction.js +5 -13
- package/cjs/myaccount/transactions/EmailTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/PhoneTransaction.js +5 -12
- package/cjs/myaccount/transactions/PhoneTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/ProfileSchemaTransaction.js +0 -5
- package/cjs/myaccount/transactions/ProfileSchemaTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/ProfileTransaction.js +0 -5
- package/cjs/myaccount/transactions/ProfileTransaction.js.map +1 -1
- package/cjs/myaccount/transactions/index.js +0 -8
- package/cjs/myaccount/transactions/index.js.map +1 -1
- package/cjs/myaccount/types.js +0 -5
- package/cjs/myaccount/types.js.map +1 -1
- package/cjs/oidc/TokenManager.js +39 -100
- package/cjs/oidc/TokenManager.js.map +1 -1
- package/cjs/oidc/TransactionManager.js +19 -26
- package/cjs/oidc/TransactionManager.js.map +1 -1
- package/cjs/oidc/decodeToken.js +1 -5
- package/cjs/oidc/decodeToken.js.map +1 -1
- package/cjs/oidc/endpoints/authorize.js +9 -13
- package/cjs/oidc/endpoints/authorize.js.map +1 -1
- package/cjs/oidc/endpoints/index.js +0 -5
- package/cjs/oidc/endpoints/index.js.map +1 -1
- package/cjs/oidc/endpoints/token.js +5 -17
- package/cjs/oidc/endpoints/token.js.map +1 -1
- package/cjs/oidc/endpoints/well-known.js +7 -14
- package/cjs/oidc/endpoints/well-known.js.map +1 -1
- package/cjs/oidc/exchangeCodeForTokens.js +7 -12
- package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
- package/cjs/oidc/factory/OktaAuthOAuth.js +0 -6
- package/cjs/oidc/factory/OktaAuthOAuth.js.map +1 -1
- package/cjs/oidc/factory/api.js +6 -20
- package/cjs/oidc/factory/api.js.map +1 -1
- package/cjs/oidc/factory/index.js +0 -3
- package/cjs/oidc/factory/index.js.map +1 -1
- package/cjs/oidc/getToken.js +18 -30
- package/cjs/oidc/getToken.js.map +1 -1
- package/cjs/oidc/getUserInfo.js +1 -15
- package/cjs/oidc/getUserInfo.js.map +1 -1
- package/cjs/oidc/getWithPopup.js +4 -8
- package/cjs/oidc/getWithPopup.js.map +1 -1
- package/cjs/oidc/getWithRedirect.js +1 -8
- package/cjs/oidc/getWithRedirect.js.map +1 -1
- package/cjs/oidc/getWithoutPrompt.js +1 -5
- package/cjs/oidc/getWithoutPrompt.js.map +1 -1
- package/cjs/oidc/handleOAuthResponse.js +23 -40
- package/cjs/oidc/handleOAuthResponse.js.map +1 -1
- package/cjs/oidc/index.js +0 -32
- package/cjs/oidc/index.js.map +1 -1
- package/cjs/oidc/mixin/browser.js +6 -18
- package/cjs/oidc/mixin/browser.js.map +1 -1
- package/cjs/oidc/mixin/index.js +37 -89
- package/cjs/oidc/mixin/index.js.map +1 -1
- package/cjs/oidc/mixin/node.js +2 -9
- package/cjs/oidc/mixin/node.js.map +1 -1
- package/cjs/oidc/options/OAuthOptionsConstructor.js +17 -24
- package/cjs/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/cjs/oidc/options/browser.js.map +1 -1
- package/cjs/oidc/options/index.js +0 -1
- package/cjs/oidc/options/index.js.map +1 -1
- package/cjs/oidc/options/node.js.map +1 -1
- package/cjs/oidc/parseFromUrl.js +1 -32
- package/cjs/oidc/parseFromUrl.js.map +1 -1
- package/cjs/oidc/renewToken.js +5 -16
- package/cjs/oidc/renewToken.js.map +1 -1
- package/cjs/oidc/renewTokens.js +3 -15
- package/cjs/oidc/renewTokens.js.map +1 -1
- package/cjs/oidc/renewTokensWithRefresh.js +3 -13
- package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
- package/cjs/oidc/revokeToken.js +3 -14
- package/cjs/oidc/revokeToken.js.map +1 -1
- package/cjs/oidc/storage.js +0 -8
- package/cjs/oidc/storage.js.map +1 -1
- package/cjs/oidc/types/Token.js +1 -5
- package/cjs/oidc/types/Token.js.map +1 -1
- package/cjs/oidc/types/TokenManager.js +1 -1
- package/cjs/oidc/types/TokenManager.js.map +1 -1
- package/cjs/oidc/types/Transaction.js +1 -12
- package/cjs/oidc/types/Transaction.js.map +1 -1
- package/cjs/oidc/types/UserClaims.js.map +1 -1
- package/cjs/oidc/types/api.js.map +1 -1
- package/cjs/oidc/types/index.js +0 -21
- package/cjs/oidc/types/index.js.map +1 -1
- package/cjs/oidc/types/meta.js.map +1 -1
- package/cjs/oidc/types/options.js.map +1 -1
- package/cjs/oidc/types/proto.js.map +1 -1
- package/cjs/oidc/util/browser.js +4 -13
- package/cjs/oidc/util/browser.js.map +1 -1
- package/cjs/oidc/util/defaultTokenParams.js +5 -5
- package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
- package/cjs/oidc/util/errors.js +3 -8
- package/cjs/oidc/util/errors.js.map +1 -1
- package/cjs/oidc/util/index.js +0 -24
- package/cjs/oidc/util/index.js.map +1 -1
- package/cjs/oidc/util/loginRedirect.js +11 -25
- package/cjs/oidc/util/loginRedirect.js.map +1 -1
- package/cjs/oidc/util/oauth.js +3 -12
- package/cjs/oidc/util/oauth.js.map +1 -1
- package/cjs/oidc/util/oauthMeta.js +5 -6
- package/cjs/oidc/util/oauthMeta.js.map +1 -1
- package/cjs/oidc/util/pkce.js +1 -12
- package/cjs/oidc/util/pkce.js.map +1 -1
- package/cjs/oidc/util/prepareTokenParams.js +13 -26
- package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
- package/cjs/oidc/util/refreshToken.js +0 -7
- package/cjs/oidc/util/refreshToken.js.map +1 -1
- package/cjs/oidc/util/sharedStorage.js +0 -8
- package/cjs/oidc/util/sharedStorage.js.map +1 -1
- package/cjs/oidc/util/urlParams.js +9 -12
- package/cjs/oidc/util/urlParams.js.map +1 -1
- package/cjs/oidc/util/validateClaims.js +9 -17
- package/cjs/oidc/util/validateClaims.js.map +1 -1
- package/cjs/oidc/util/validateToken.js +1 -6
- package/cjs/oidc/util/validateToken.js.map +1 -1
- package/cjs/oidc/verifyToken.js +13 -23
- package/cjs/oidc/verifyToken.js.map +1 -1
- package/cjs/server/serverStorage.js +9 -27
- package/cjs/server/serverStorage.js.map +1 -1
- package/cjs/services/AutoRenewService.js +1 -17
- package/cjs/services/AutoRenewService.js.map +1 -1
- package/cjs/services/LeaderElectionService.js +1 -23
- package/cjs/services/LeaderElectionService.js.map +1 -1
- package/cjs/services/SyncStorageService.js +3 -37
- package/cjs/services/SyncStorageService.js.map +1 -1
- package/cjs/services/index.js +0 -5
- package/cjs/services/index.js.map +1 -1
- package/cjs/session/api.js +1 -12
- package/cjs/session/api.js.map +1 -1
- package/cjs/session/factory.js +0 -2
- package/cjs/session/factory.js.map +1 -1
- package/cjs/session/index.js +0 -7
- package/cjs/session/index.js.map +1 -1
- package/cjs/session/mixin.js +2 -6
- package/cjs/session/mixin.js.map +1 -1
- package/cjs/storage/BaseStorageManager.js +13 -25
- package/cjs/storage/BaseStorageManager.js.map +1 -1
- package/cjs/storage/SavedObject.js +7 -19
- package/cjs/storage/SavedObject.js.map +1 -1
- package/cjs/storage/index.js +0 -9
- package/cjs/storage/index.js.map +1 -1
- package/cjs/storage/mixin.js +2 -4
- package/cjs/storage/mixin.js.map +1 -1
- package/cjs/storage/options/StorageOptionsConstructor.js +3 -6
- package/cjs/storage/options/StorageOptionsConstructor.js.map +1 -1
- package/cjs/storage/options/browser.js +7 -15
- package/cjs/storage/options/browser.js.map +1 -1
- package/cjs/storage/options/node.js +3 -6
- package/cjs/storage/options/node.js.map +1 -1
- package/cjs/util/PromiseQueue.js +7 -15
- package/cjs/util/PromiseQueue.js.map +1 -1
- package/cjs/util/console.js +3 -7
- package/cjs/util/console.js.map +1 -1
- package/cjs/util/index.js +0 -11
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/misc.js +3 -8
- package/cjs/util/misc.js.map +1 -1
- package/cjs/util/object.js +9 -23
- package/cjs/util/object.js.map +1 -1
- package/cjs/util/types.js +1 -5
- package/cjs/util/types.js.map +1 -1
- package/cjs/util/url.js +5 -14
- package/cjs/util/url.js.map +1 -1
- package/dist/okta-auth-js.authn.min.analyzer.html +3 -3
- package/dist/okta-auth-js.authn.min.js +1 -1
- package/dist/okta-auth-js.authn.min.js.LICENSE.txt +2 -0
- package/dist/okta-auth-js.authn.min.js.map +1 -1
- package/dist/okta-auth-js.core.min.analyzer.html +3 -3
- package/dist/okta-auth-js.core.min.js +1 -1
- package/dist/okta-auth-js.core.min.js.LICENSE.txt +2 -0
- package/dist/okta-auth-js.core.min.js.map +1 -1
- package/dist/okta-auth-js.idx.min.analyzer.html +3 -3
- package/dist/okta-auth-js.idx.min.js +1 -1
- package/dist/okta-auth-js.idx.min.js.LICENSE.txt +2 -0
- package/dist/okta-auth-js.idx.min.js.map +1 -1
- package/dist/okta-auth-js.min.analyzer.html +3 -3
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.LICENSE.txt +2 -0
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.myaccount.min.analyzer.html +3 -3
- package/dist/okta-auth-js.myaccount.min.js +1 -1
- package/dist/okta-auth-js.myaccount.min.js.LICENSE.txt +2 -0
- package/dist/okta-auth-js.myaccount.min.js.map +1 -1
- package/dist/okta-auth-js.polyfill.js +1 -1
- package/dist/okta-auth-js.polyfill.js.map +1 -1
- package/esm/browser/http/OktaUserAgent.js +2 -2
- package/esm/browser/http/request.js +56 -23
- package/esm/browser/http/request.js.map +1 -1
- package/esm/browser/idx/interact.js +2 -2
- package/esm/browser/idx/interact.js.map +1 -1
- package/esm/browser/idx/run.js +3 -2
- package/esm/browser/idx/run.js.map +1 -1
- package/esm/browser/idx/transactionMeta.js +3 -2
- package/esm/browser/idx/transactionMeta.js.map +1 -1
- package/esm/browser/myaccount/request.js +2 -43
- package/esm/browser/myaccount/request.js.map +1 -1
- package/esm/browser/oidc/endpoints/authorize.js +1 -0
- package/esm/browser/oidc/endpoints/authorize.js.map +1 -1
- package/esm/browser/oidc/exchangeCodeForTokens.js +2 -1
- package/esm/browser/oidc/exchangeCodeForTokens.js.map +1 -1
- package/esm/browser/oidc/handleOAuthResponse.js +17 -16
- package/esm/browser/oidc/handleOAuthResponse.js.map +1 -1
- package/esm/browser/oidc/options/OAuthOptionsConstructor.js +2 -0
- package/esm/browser/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/esm/browser/oidc/util/defaultTokenParams.js +3 -1
- package/esm/browser/oidc/util/defaultTokenParams.js.map +1 -1
- package/esm/browser/oidc/util/oauthMeta.js +1 -0
- package/esm/browser/oidc/util/oauthMeta.js.map +1 -1
- package/esm/browser/oidc/util/validateClaims.js +9 -4
- package/esm/browser/oidc/util/validateClaims.js.map +1 -1
- package/esm/browser/oidc/verifyToken.js +2 -2
- package/esm/browser/oidc/verifyToken.js.map +1 -1
- package/esm/browser/package.json +1 -1
- package/esm/node/http/OktaUserAgent.js +2 -2
- package/esm/node/http/request.js +56 -23
- package/esm/node/http/request.js.map +1 -1
- package/esm/node/idx/interact.js +2 -2
- package/esm/node/idx/interact.js.map +1 -1
- package/esm/node/idx/run.js +3 -2
- package/esm/node/idx/run.js.map +1 -1
- package/esm/node/idx/transactionMeta.js +3 -2
- package/esm/node/idx/transactionMeta.js.map +1 -1
- package/esm/node/myaccount/request.js +2 -43
- package/esm/node/myaccount/request.js.map +1 -1
- package/esm/node/oidc/endpoints/authorize.js +1 -0
- package/esm/node/oidc/endpoints/authorize.js.map +1 -1
- package/esm/node/oidc/exchangeCodeForTokens.js +2 -1
- package/esm/node/oidc/exchangeCodeForTokens.js.map +1 -1
- package/esm/node/oidc/handleOAuthResponse.js +17 -16
- package/esm/node/oidc/handleOAuthResponse.js.map +1 -1
- package/esm/node/oidc/options/OAuthOptionsConstructor.js +2 -0
- package/esm/node/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/esm/node/oidc/util/defaultTokenParams.js +3 -1
- package/esm/node/oidc/util/defaultTokenParams.js.map +1 -1
- package/esm/node/oidc/util/oauthMeta.js +1 -0
- package/esm/node/oidc/util/oauthMeta.js.map +1 -1
- package/esm/node/oidc/util/validateClaims.js +9 -4
- package/esm/node/oidc/util/validateClaims.js.map +1 -1
- package/esm/node/oidc/verifyToken.js +2 -2
- package/esm/node/oidc/verifyToken.js.map +1 -1
- package/esm/node/package.json +1 -1
- package/package.json +12 -13
- package/polyfill/index.js +8 -5
- package/types/lib/core/options.d.ts +2 -0
- package/types/lib/idx/interact.d.ts +1 -0
- package/types/lib/idx/options.d.ts +2 -0
- package/types/lib/idx/types/meta.d.ts +1 -0
- package/types/lib/idx/types/options.d.ts +1 -0
- package/types/lib/oidc/options/OAuthOptionsConstructor.d.ts +2 -0
- package/types/lib/oidc/types/UserClaims.d.ts +1 -0
- package/types/lib/oidc/types/api.d.ts +1 -0
- package/types/lib/oidc/types/meta.d.ts +1 -1
- package/types/lib/oidc/types/options.d.ts +2 -1
- package/types/lib/oidc/types/proto.d.ts +1 -0
- package/umd/authn.js +1 -1
- package/umd/authn.js.LICENSE.txt +2 -0
- package/umd/authn.js.map +1 -1
- package/umd/core.js +1 -1
- package/umd/core.js.LICENSE.txt +2 -0
- package/umd/core.js.map +1 -1
- package/umd/default.js +1 -1
- package/umd/default.js.LICENSE.txt +2 -0
- package/umd/default.js.map +1 -1
- package/umd/idx.js +1 -1
- package/umd/idx.js.LICENSE.txt +2 -0
- package/umd/idx.js.map +1 -1
- package/umd/myaccount.js +1 -1
- package/umd/myaccount.js.LICENSE.txt +2 -0
- package/umd/myaccount.js.map +1 -1
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.exchangeCodeForTokens = exchangeCodeForTokens;
|
|
4
|
-
|
|
5
4
|
var _util = require("./util");
|
|
6
|
-
|
|
7
5
|
var _util2 = require("../util");
|
|
8
|
-
|
|
9
6
|
var _token = require("./endpoints/token");
|
|
10
|
-
|
|
11
7
|
var _handleOAuthResponse = require("./handleOAuthResponse");
|
|
12
|
-
|
|
13
8
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
14
|
-
|
|
15
9
|
/* eslint-disable max-len */
|
|
16
|
-
|
|
17
10
|
/*!
|
|
18
11
|
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
19
12
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -26,10 +19,11 @@ var _handleOAuthResponse = require("./handleOAuthResponse");
|
|
|
26
19
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
27
20
|
*
|
|
28
21
|
*/
|
|
22
|
+
|
|
29
23
|
// codeVerifier is required. May pass either an authorizationCode or interactionCode
|
|
30
24
|
function exchangeCodeForTokens(sdk, tokenParams, urls) {
|
|
31
|
-
urls = urls || (0, _util.getOAuthUrls)(sdk, tokenParams);
|
|
32
|
-
|
|
25
|
+
urls = urls || (0, _util.getOAuthUrls)(sdk, tokenParams);
|
|
26
|
+
// build params using defaults + options
|
|
33
27
|
tokenParams = Object.assign({}, (0, _util.getDefaultTokenParams)(sdk), (0, _util2.clone)(tokenParams));
|
|
34
28
|
const {
|
|
35
29
|
authorizationCode,
|
|
@@ -39,7 +33,8 @@ function exchangeCodeForTokens(sdk, tokenParams, urls) {
|
|
|
39
33
|
redirectUri,
|
|
40
34
|
scopes,
|
|
41
35
|
ignoreSignature,
|
|
42
|
-
state
|
|
36
|
+
state,
|
|
37
|
+
acrValues
|
|
43
38
|
} = tokenParams;
|
|
44
39
|
var getTokenOptions = {
|
|
45
40
|
clientId,
|
|
@@ -53,7 +48,6 @@ function exchangeCodeForTokens(sdk, tokenParams, urls) {
|
|
|
53
48
|
// Here we modify the response from `/token` so that it more closely matches a response from `/authorize`
|
|
54
49
|
// `responseType` is used to validate that the expected tokens were returned
|
|
55
50
|
const responseType = ['token']; // an accessToken will always be returned
|
|
56
|
-
|
|
57
51
|
if (scopes.indexOf('openid') !== -1) {
|
|
58
52
|
responseType.push('id_token'); // an idToken will be returned if "openid" is in the scopes
|
|
59
53
|
}
|
|
@@ -63,7 +57,8 @@ function exchangeCodeForTokens(sdk, tokenParams, urls) {
|
|
|
63
57
|
redirectUri,
|
|
64
58
|
scopes,
|
|
65
59
|
responseType,
|
|
66
|
-
ignoreSignature
|
|
60
|
+
ignoreSignature,
|
|
61
|
+
acrValues
|
|
67
62
|
};
|
|
68
63
|
return (0, _handleOAuthResponse.handleOAuthResponse)(sdk, handleResponseOptions, response, urls).then(response => {
|
|
69
64
|
// For compatibility, "code" is returned in the TokenResponse. OKTA-326091
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchangeCodeForTokens.js","names":["exchangeCodeForTokens","sdk","tokenParams","urls","getOAuthUrls","Object","assign","getDefaultTokenParams","clone","authorizationCode","interactionCode","codeVerifier","clientId","redirectUri","scopes","ignoreSignature","state","getTokenOptions","postToTokenEndpoint","then","response","responseType","indexOf","push","handleResponseOptions","handleOAuthResponse","code","finally","transactionManager","clear"],"sources":["../../../lib/oidc/exchangeCodeForTokens.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* 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 { CustomUrls, OAuthResponse, OAuthResponseType, OktaAuthOAuthInterface, TokenParams, TokenResponse } from './types';\nimport { getOAuthUrls, 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: OktaAuthOAuthInterface, 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: OAuthResponseType[] = ['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}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"exchangeCodeForTokens.js","names":["exchangeCodeForTokens","sdk","tokenParams","urls","getOAuthUrls","Object","assign","getDefaultTokenParams","clone","authorizationCode","interactionCode","codeVerifier","clientId","redirectUri","scopes","ignoreSignature","state","acrValues","getTokenOptions","postToTokenEndpoint","then","response","responseType","indexOf","push","handleResponseOptions","handleOAuthResponse","code","finally","transactionManager","clear"],"sources":["../../../lib/oidc/exchangeCodeForTokens.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* 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 { CustomUrls, OAuthResponse, OAuthResponseType, OktaAuthOAuthInterface, TokenParams, TokenResponse } from './types';\nimport { getOAuthUrls, 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: OktaAuthOAuthInterface, 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 acrValues\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: OAuthResponseType[] = ['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 acrValues\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}"],"mappings":";;;AAeA;AACA;AACA;AACA;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACO,SAASA,qBAAqB,CAACC,GAA2B,EAAEC,WAAwB,EAAEC,IAAiB,EAA0B;EACtIA,IAAI,GAAGA,IAAI,IAAI,IAAAC,kBA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1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.createOktaAuthOAuth = createOktaAuthOAuth;
|
|
4
|
-
|
|
5
4
|
var _base = require("../../base");
|
|
6
|
-
|
|
7
5
|
var _mixin = require("../../storage/mixin");
|
|
8
|
-
|
|
9
6
|
var _mixin2 = require("../../session/mixin");
|
|
10
|
-
|
|
11
7
|
var _mixin3 = require("../../http/mixin");
|
|
12
|
-
|
|
13
8
|
var _mixin4 = require("../mixin");
|
|
14
|
-
|
|
15
9
|
function createOktaAuthOAuth(StorageManagerConstructor, OptionsConstructor, TransactionManagerConstructor) {
|
|
16
10
|
const Base = (0, _base.createOktaAuthBase)(OptionsConstructor);
|
|
17
11
|
const WithStorage = (0, _mixin.mixinStorage)(Base, StorageManagerConstructor);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OktaAuthOAuth.js","names":["createOktaAuthOAuth","StorageManagerConstructor","OptionsConstructor","TransactionManagerConstructor","Base","createOktaAuthBase","WithStorage","mixinStorage","WithHttp","mixinHttp","WithSession","mixinSession","WithOAuth","mixinOAuth"],"sources":["../../../../lib/oidc/factory/OktaAuthOAuth.ts"],"sourcesContent":["import { StorageManagerConstructor } from '../../storage/types';\nimport { OktaAuthConstructor, OktaAuthOptionsConstructor } from '../../base/types';\n\nimport { createOktaAuthBase } from '../../base';\nimport { mixinStorage } from '../../storage/mixin';\nimport { mixinSession } from '../../session/mixin';\nimport { mixinHttp } from '../../http/mixin';\nimport { mixinOAuth } from '../mixin';\nimport {\n OAuthTransactionMeta,\n OktaAuthOAuthInterface,\n OktaAuthOAuthOptions,\n OAuthStorageManagerInterface,\n PKCETransactionMeta,\n TransactionManagerConstructor,\n TransactionManagerInterface\n} from '../types';\n\nexport function createOktaAuthOAuth\n<\n M extends OAuthTransactionMeta = PKCETransactionMeta,\n S extends OAuthStorageManagerInterface<M> = OAuthStorageManagerInterface<M>,\n O extends OktaAuthOAuthOptions = OktaAuthOAuthOptions,\n TM extends TransactionManagerInterface = TransactionManagerInterface\n>\n(\n StorageManagerConstructor: StorageManagerConstructor<S>,\n OptionsConstructor: OktaAuthOptionsConstructor<O>,\n TransactionManagerConstructor: TransactionManagerConstructor<TM>\n): OktaAuthConstructor<OktaAuthOAuthInterface<M, S, O, TM>>\n{\n const Base = createOktaAuthBase(OptionsConstructor);\n const WithStorage = mixinStorage<S, O>(Base, StorageManagerConstructor);\n const WithHttp = mixinHttp<S, O>(WithStorage);\n const WithSession = mixinSession<S, O>(WithHttp);\n const WithOAuth = mixinOAuth<M, S, O, TM>(WithSession, TransactionManagerConstructor);\n return WithOAuth;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"OktaAuthOAuth.js","names":["createOktaAuthOAuth","StorageManagerConstructor","OptionsConstructor","TransactionManagerConstructor","Base","createOktaAuthBase","WithStorage","mixinStorage","WithHttp","mixinHttp","WithSession","mixinSession","WithOAuth","mixinOAuth"],"sources":["../../../../lib/oidc/factory/OktaAuthOAuth.ts"],"sourcesContent":["import { StorageManagerConstructor } from '../../storage/types';\nimport { OktaAuthConstructor, OktaAuthOptionsConstructor } from '../../base/types';\n\nimport { createOktaAuthBase } from '../../base';\nimport { mixinStorage } from '../../storage/mixin';\nimport { mixinSession } from '../../session/mixin';\nimport { mixinHttp } from '../../http/mixin';\nimport { mixinOAuth } from '../mixin';\nimport {\n OAuthTransactionMeta,\n OktaAuthOAuthInterface,\n OktaAuthOAuthOptions,\n OAuthStorageManagerInterface,\n PKCETransactionMeta,\n TransactionManagerConstructor,\n TransactionManagerInterface\n} from '../types';\n\nexport function createOktaAuthOAuth\n<\n M extends OAuthTransactionMeta = PKCETransactionMeta,\n S extends OAuthStorageManagerInterface<M> = OAuthStorageManagerInterface<M>,\n O extends OktaAuthOAuthOptions = OktaAuthOAuthOptions,\n TM extends TransactionManagerInterface = TransactionManagerInterface\n>\n(\n StorageManagerConstructor: StorageManagerConstructor<S>,\n OptionsConstructor: OktaAuthOptionsConstructor<O>,\n TransactionManagerConstructor: TransactionManagerConstructor<TM>\n): OktaAuthConstructor<OktaAuthOAuthInterface<M, S, O, TM>>\n{\n const Base = createOktaAuthBase(OptionsConstructor);\n const WithStorage = mixinStorage<S, O>(Base, StorageManagerConstructor);\n const WithHttp = mixinHttp<S, O>(WithStorage);\n const WithSession = mixinSession<S, O>(WithHttp);\n const WithOAuth = mixinOAuth<M, S, O, TM>(WithSession, TransactionManagerConstructor);\n return WithOAuth;\n}\n"],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AAWO,SAASA,mBAAmB,CAQjCC,yBAAuD,EACvDC,kBAAiD,EACjDC,6BAAgE,EAElE;EACE,MAAMC,IAAI,GAAG,IAAAC,wBAAkB,EAACH,kBAAkB,CAAC;EACnD,MAAMI,WAAW,GAAG,IAAAC,mBAAY,EAAOH,IAAI,EAAEH,yBAAyB,CAAC;EACvE,MAAMO,QAAQ,GAAG,IAAAC,iBAAS,EAAOH,WAAW,CAAC;EAC7C,MAAMI,WAAW,GAAG,IAAAC,oBAAY,EAAOH,QAAQ,CAAC;EAChD,MAAMI,SAAS,GAAG,IAAAC,kBAAU,EAAcH,WAAW,EAAEP,6BAA6B,CAAC;EACrF,OAAOS,SAAS;AAClB"}
|
package/cjs/oidc/factory/api.js
CHANGED
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.createTokenAPI = createTokenAPI;
|
|
4
|
-
|
|
5
4
|
var _util = require("../../util");
|
|
6
|
-
|
|
7
5
|
var _decodeToken = require("../decodeToken");
|
|
8
|
-
|
|
9
6
|
var _exchangeCodeForTokens = require("../exchangeCodeForTokens");
|
|
10
|
-
|
|
11
7
|
var _getUserInfo = require("../getUserInfo");
|
|
12
|
-
|
|
13
8
|
var _getWithoutPrompt = require("../getWithoutPrompt");
|
|
14
|
-
|
|
15
9
|
var _getWithPopup = require("../getWithPopup");
|
|
16
|
-
|
|
17
10
|
var _getWithRedirect = require("../getWithRedirect");
|
|
18
|
-
|
|
19
11
|
var _parseFromUrl = require("../parseFromUrl");
|
|
20
|
-
|
|
21
12
|
var _renewToken = require("../renewToken");
|
|
22
|
-
|
|
23
13
|
var _renewTokens = require("../renewTokens");
|
|
24
|
-
|
|
25
14
|
var _renewTokensWithRefresh = require("../renewTokensWithRefresh");
|
|
26
|
-
|
|
27
15
|
var _revokeToken = require("../revokeToken");
|
|
28
|
-
|
|
29
16
|
var _util2 = require("../util");
|
|
30
|
-
|
|
31
17
|
var _verifyToken = require("../verifyToken");
|
|
32
|
-
|
|
33
18
|
/*!
|
|
34
19
|
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
35
20
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -42,12 +27,12 @@ var _verifyToken = require("../verifyToken");
|
|
|
42
27
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
43
28
|
*
|
|
44
29
|
*/
|
|
30
|
+
|
|
45
31
|
// Factory
|
|
46
32
|
function createTokenAPI(sdk, queue) {
|
|
47
33
|
const useQueue = method => {
|
|
48
34
|
return _util.PromiseQueue.prototype.push.bind(queue, method, null);
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
const getWithRedirectFn = useQueue(_getWithRedirect.getWithRedirect.bind(null, sdk));
|
|
52
37
|
const getWithRedirectApi = Object.assign(getWithRedirectFn, {
|
|
53
38
|
// This is exposed so we can set window.location in our tests
|
|
@@ -58,8 +43,8 @@ function createTokenAPI(sdk, queue) {
|
|
|
58
43
|
window.location = url;
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
|
-
});
|
|
62
|
-
|
|
46
|
+
});
|
|
47
|
+
// eslint-disable-next-line max-len
|
|
63
48
|
const parseFromUrlFn = useQueue(_parseFromUrl.parseFromUrl.bind(null, sdk));
|
|
64
49
|
const parseFromUrlApi = Object.assign(parseFromUrlFn, {
|
|
65
50
|
// This is exposed so we can mock getting window.history in our tests
|
|
@@ -92,9 +77,10 @@ function createTokenAPI(sdk, queue) {
|
|
|
92
77
|
},
|
|
93
78
|
verify: _verifyToken.verifyToken.bind(null, sdk),
|
|
94
79
|
isLoginRedirect: _util2.isLoginRedirect.bind(null, sdk)
|
|
95
|
-
};
|
|
96
|
-
// 'getWithRedirect' and 'parseFromUrl' are already wrapped
|
|
80
|
+
};
|
|
97
81
|
|
|
82
|
+
// Wrap certain async token API methods using PromiseQueue to avoid issues with concurrency
|
|
83
|
+
// 'getWithRedirect' and 'parseFromUrl' are already wrapped
|
|
98
84
|
const toWrap = ['getWithoutPrompt', 'getWithPopup', 'revoke', 'renew', 'renewTokensWithRefresh', 'renewTokens'];
|
|
99
85
|
toWrap.forEach(key => {
|
|
100
86
|
token[key] = useQueue(token[key]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":["createTokenAPI","sdk","queue","useQueue","method","PromiseQueue","prototype","push","bind","getWithRedirectFn","getWithRedirect","getWithRedirectApi","Object","assign","_setLocation","url","options","setLocation","window","location","parseFromUrlFn","parseFromUrl","parseFromUrlApi","_getHistory","history","_getLocation","_getDocument","document","token","prepareTokenParams","exchangeCodeForTokens","getWithoutPrompt","getWithPopup","decode","decodeToken","revoke","revokeToken","renew","renewToken","renewTokensWithRefresh","renewTokens","getUserInfo","accessTokenObject","idTokenObject","verify","verifyToken","isLoginRedirect","toWrap","forEach","key"],"sources":["../../../../lib/oidc/factory/api.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\n\nimport { PromiseQueue } from '../../util';\nimport { decodeToken } from '../decodeToken';\nimport { exchangeCodeForTokens } from '../exchangeCodeForTokens';\nimport { getUserInfo } from '../getUserInfo';\nimport { getWithoutPrompt } from '../getWithoutPrompt';\nimport { getWithPopup } from '../getWithPopup';\nimport { getWithRedirect } from '../getWithRedirect';\nimport { parseFromUrl } from '../parseFromUrl';\nimport { renewToken } from '../renewToken';\nimport { renewTokens } from '../renewTokens';\nimport { renewTokensWithRefresh } from '../renewTokensWithRefresh';\nimport { revokeToken } from '../revokeToken';\nimport {\n AccessToken,\n CustomUserClaims,\n GetWithRedirectAPI,\n GetWithRedirectFunction,\n IDToken,\n OktaAuthOAuthInterface,\n ParseFromUrlInterface,\n TokenAPI,\n UserClaims\n} from '../types';\nimport { isLoginRedirect, prepareTokenParams } from '../util';\nimport { verifyToken } from '../verifyToken';\n\n// Factory\nexport function createTokenAPI(sdk: OktaAuthOAuthInterface, queue: PromiseQueue): TokenAPI {\n const useQueue = (method) => {\n return PromiseQueue.prototype.push.bind(queue, method, null);\n };\n\n const getWithRedirectFn = useQueue(getWithRedirect.bind(null, sdk)) as GetWithRedirectFunction;\n const getWithRedirectApi: GetWithRedirectAPI = Object.assign(getWithRedirectFn, {\n // This is exposed so we can set window.location in our tests\n _setLocation: (url) => {\n if (sdk.options.setLocation) {\n sdk.options.setLocation(url);\n } else {\n window.location = url;\n }\n }\n });\n // eslint-disable-next-line max-len\n const parseFromUrlFn = useQueue(parseFromUrl.bind(null, sdk)) as ParseFromUrlInterface;\n const parseFromUrlApi: ParseFromUrlInterface = Object.assign(parseFromUrlFn, {\n // This is exposed so we can mock getting window.history in our tests\n _getHistory: function() {\n return window.history;\n },\n\n // This is exposed so we can mock getting window.location in our tests\n _getLocation: function() {\n return window.location;\n },\n\n // This is exposed so we can mock getting window.document in our tests\n _getDocument: function() {\n return window.document;\n }\n });\n\n const token: TokenAPI ={\n prepareTokenParams: prepareTokenParams.bind(null, sdk),\n exchangeCodeForTokens: exchangeCodeForTokens.bind(null, sdk),\n getWithoutPrompt: getWithoutPrompt.bind(null, sdk),\n getWithPopup: getWithPopup.bind(null, sdk),\n getWithRedirect: getWithRedirectApi,\n parseFromUrl: parseFromUrlApi,\n decode: decodeToken,\n revoke: revokeToken.bind(null, sdk),\n renew: renewToken.bind(null, sdk),\n renewTokensWithRefresh: renewTokensWithRefresh.bind(null, sdk),\n renewTokens: renewTokens.bind(null, sdk),\n getUserInfo: <C extends CustomUserClaims = CustomUserClaims>(\n accessTokenObject: AccessToken,\n idTokenObject: IDToken\n ): Promise<UserClaims<C>> => {\n return getUserInfo(sdk, accessTokenObject, idTokenObject);\n },\n verify: verifyToken.bind(null, sdk),\n isLoginRedirect: isLoginRedirect.bind(null, sdk)\n };\n\n // Wrap certain async token API methods using PromiseQueue to avoid issues with concurrency\n // 'getWithRedirect' and 'parseFromUrl' are already wrapped\n const toWrap = [\n 'getWithoutPrompt',\n 'getWithPopup',\n 'revoke',\n 'renew',\n 'renewTokensWithRefresh',\n 'renewTokens'\n ];\n toWrap.forEach(key => {\n token[key] = useQueue(token[key]);\n });\n\n return token;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","names":["createTokenAPI","sdk","queue","useQueue","method","PromiseQueue","prototype","push","bind","getWithRedirectFn","getWithRedirect","getWithRedirectApi","Object","assign","_setLocation","url","options","setLocation","window","location","parseFromUrlFn","parseFromUrl","parseFromUrlApi","_getHistory","history","_getLocation","_getDocument","document","token","prepareTokenParams","exchangeCodeForTokens","getWithoutPrompt","getWithPopup","decode","decodeToken","revoke","revokeToken","renew","renewToken","renewTokensWithRefresh","renewTokens","getUserInfo","accessTokenObject","idTokenObject","verify","verifyToken","isLoginRedirect","toWrap","forEach","key"],"sources":["../../../../lib/oidc/factory/api.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n *\n */\n\nimport { PromiseQueue } from '../../util';\nimport { decodeToken } from '../decodeToken';\nimport { exchangeCodeForTokens } from '../exchangeCodeForTokens';\nimport { getUserInfo } from '../getUserInfo';\nimport { getWithoutPrompt } from '../getWithoutPrompt';\nimport { getWithPopup } from '../getWithPopup';\nimport { getWithRedirect } from '../getWithRedirect';\nimport { parseFromUrl } from '../parseFromUrl';\nimport { renewToken } from '../renewToken';\nimport { renewTokens } from '../renewTokens';\nimport { renewTokensWithRefresh } from '../renewTokensWithRefresh';\nimport { revokeToken } from '../revokeToken';\nimport {\n AccessToken,\n CustomUserClaims,\n GetWithRedirectAPI,\n GetWithRedirectFunction,\n IDToken,\n OktaAuthOAuthInterface,\n ParseFromUrlInterface,\n TokenAPI,\n UserClaims\n} from '../types';\nimport { isLoginRedirect, prepareTokenParams } from '../util';\nimport { verifyToken } from '../verifyToken';\n\n// Factory\nexport function createTokenAPI(sdk: OktaAuthOAuthInterface, queue: PromiseQueue): TokenAPI {\n const useQueue = (method) => {\n return PromiseQueue.prototype.push.bind(queue, method, null);\n };\n\n const getWithRedirectFn = useQueue(getWithRedirect.bind(null, sdk)) as GetWithRedirectFunction;\n const getWithRedirectApi: GetWithRedirectAPI = Object.assign(getWithRedirectFn, {\n // This is exposed so we can set window.location in our tests\n _setLocation: (url) => {\n if (sdk.options.setLocation) {\n sdk.options.setLocation(url);\n } else {\n window.location = url;\n }\n }\n });\n // eslint-disable-next-line max-len\n const parseFromUrlFn = useQueue(parseFromUrl.bind(null, sdk)) as ParseFromUrlInterface;\n const parseFromUrlApi: ParseFromUrlInterface = Object.assign(parseFromUrlFn, {\n // This is exposed so we can mock getting window.history in our tests\n _getHistory: function() {\n return window.history;\n },\n\n // This is exposed so we can mock getting window.location in our tests\n _getLocation: function() {\n return window.location;\n },\n\n // This is exposed so we can mock getting window.document in our tests\n _getDocument: function() {\n return window.document;\n }\n });\n\n const token: TokenAPI ={\n prepareTokenParams: prepareTokenParams.bind(null, sdk),\n exchangeCodeForTokens: exchangeCodeForTokens.bind(null, sdk),\n getWithoutPrompt: getWithoutPrompt.bind(null, sdk),\n getWithPopup: getWithPopup.bind(null, sdk),\n getWithRedirect: getWithRedirectApi,\n parseFromUrl: parseFromUrlApi,\n decode: decodeToken,\n revoke: revokeToken.bind(null, sdk),\n renew: renewToken.bind(null, sdk),\n renewTokensWithRefresh: renewTokensWithRefresh.bind(null, sdk),\n renewTokens: renewTokens.bind(null, sdk),\n getUserInfo: <C extends CustomUserClaims = CustomUserClaims>(\n accessTokenObject: AccessToken,\n idTokenObject: IDToken\n ): Promise<UserClaims<C>> => {\n return getUserInfo(sdk, accessTokenObject, idTokenObject);\n },\n verify: verifyToken.bind(null, sdk),\n isLoginRedirect: isLoginRedirect.bind(null, sdk)\n };\n\n // Wrap certain async token API methods using PromiseQueue to avoid issues with concurrency\n // 'getWithRedirect' and 'parseFromUrl' are already wrapped\n const toWrap = [\n 'getWithoutPrompt',\n 'getWithPopup',\n 'revoke',\n 'renew',\n 'renewTokensWithRefresh',\n 'renewTokens'\n ];\n toWrap.forEach(key => {\n token[key] = useQueue(token[key]);\n });\n\n return token;\n}\n"],"mappings":";;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA;AArCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4BA;AACO,SAASA,cAAc,CAACC,GAA2B,EAAEC,KAAmB,EAAY;EACzF,MAAMC,QAAQ,GAAIC,MAAM,IAAK;IAC3B,OAAOC,kBAAY,CAACC,SAAS,CAACC,IAAI,CAACC,IAAI,CAACN,KAAK,EAAEE,MAAM,EAAE,IAAI,CAAC;EAC9D,CAAC;EAED,MAAMK,iBAAiB,G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AI,CAAC,IAAI,EAAEP,GAAG,CAAC;IACnCoC,KAAK,EAAEC,sBAAU,CAAC9B,IAAI,CAAC,IAAI,EAAEP,GAAG,CAAC;IACjCsC,sBAAsB,EAAEA,8CAAsB,CAAC/B,IAAI,CAAC,IAAI,EAAEP,GAAG,CAAC;IAC9DuC,WAAW,EAAEA,wBAAW,CAAChC,IAAI,CAAC,IAAI,EAAEP,GAAG,CAAC;IACxCwC,WAAW,EAAE,CACXC,iBAA8B,EAC9BC,aAAsB,KACK;MAC3B,OAAO,IAAAF,wBAAW,EAACxC,GAAG,EAAEyC,iBAAiB,EAAEC,aAAa,CAAC;IAC3D,CAAC;IACDC,MAAM,EAAEC,wBAAW,CAACrC,IAAI,CAAC,IAAI,EAAEP,GAAG,CAAC;IACnC6C,eAAe,EAAEA,sBAAe,CAACtC,IAAI,CAAC,IAAI,EAAEP,GAAG;EACjD,CAAC;;EAED;EACA;EACA,MAAM8C,MAAM,GAAG,CACb,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,OAAO,EACP,wBAAwB,EACxB,aAAa,CACd;EACDA,MAAM,CAACC,OAAO,CAACC,GAAG,IAAI;IACpBrB,KAAK,CAACqB,GAAG,CAAC,GAAG9C,QAAQ,CAACyB,KAAK,CAACqB,GAAG,CAAC,CAAC;EACnC,CAAC,CAAC;EAEF,OAAOrB,KAAK;AACd"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _api = require("./api");
|
|
4
|
-
|
|
5
4
|
Object.keys(_api).forEach(function (key) {
|
|
6
5
|
if (key === "default" || key === "__esModule") return;
|
|
7
6
|
if (key in exports && exports[key] === _api[key]) return;
|
|
@@ -12,9 +11,7 @@ Object.keys(_api).forEach(function (key) {
|
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
13
|
});
|
|
15
|
-
|
|
16
14
|
var _OktaAuthOAuth = require("./OktaAuthOAuth");
|
|
17
|
-
|
|
18
15
|
Object.keys(_OktaAuthOAuth).forEach(function (key) {
|
|
19
16
|
if (key === "default" || key === "__esModule") return;
|
|
20
17
|
if (key in exports && exports[key] === _OktaAuthOAuth[key]) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../lib/oidc/factory/index.ts"],"sourcesContent":["export * from './api';\nexport * from './OktaAuthOAuth';\n"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../lib/oidc/factory/index.ts"],"sourcesContent":["export * from './api';\nexport * from './OktaAuthOAuth';\n"],"mappings":";;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/cjs/oidc/getToken.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
exports.getToken = getToken;
|
|
6
|
-
|
|
7
5
|
var _util = require("./util");
|
|
8
|
-
|
|
9
6
|
var _AuthSdkError = _interopRequireDefault(require("../errors/AuthSdkError"));
|
|
10
|
-
|
|
11
7
|
var _prepareTokenParams = require("./util/prepareTokenParams");
|
|
12
|
-
|
|
13
8
|
var _authorize = require("./endpoints/authorize");
|
|
14
|
-
|
|
15
9
|
var _handleOAuthResponse = require("./handleOAuthResponse");
|
|
16
|
-
|
|
17
10
|
/* global document */
|
|
18
|
-
|
|
19
11
|
/* eslint-disable complexity, max-statements */
|
|
20
|
-
|
|
21
12
|
/*!
|
|
22
13
|
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
23
14
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -85,10 +76,10 @@ function getToken(sdk, options) {
|
|
|
85
76
|
if (arguments.length > 2) {
|
|
86
77
|
return Promise.reject(new _AuthSdkError.default('As of version 3.0, "getToken" takes only a single set of options'));
|
|
87
78
|
}
|
|
79
|
+
options = options || {};
|
|
88
80
|
|
|
89
|
-
|
|
81
|
+
// window object cannot be serialized, save for later use
|
|
90
82
|
// TODO: move popup related params into a separate options object
|
|
91
|
-
|
|
92
83
|
const popupWindow = options.popupWindow;
|
|
93
84
|
options.popupWindow = undefined;
|
|
94
85
|
return (0, _prepareTokenParams.prepareTokenParams)(sdk, options).then(function (tokenParams) {
|
|
@@ -101,31 +92,31 @@ function getToken(sdk, options) {
|
|
|
101
92
|
var idpOverrides = {
|
|
102
93
|
display: 'popup'
|
|
103
94
|
};
|
|
104
|
-
|
|
105
95
|
if (options.sessionToken) {
|
|
106
96
|
Object.assign(tokenParams, sessionTokenOverrides);
|
|
107
97
|
} else if (options.idp) {
|
|
108
98
|
Object.assign(tokenParams, idpOverrides);
|
|
109
|
-
}
|
|
110
|
-
|
|
99
|
+
}
|
|
111
100
|
|
|
112
|
-
|
|
101
|
+
// Use the query params to build the authorize url
|
|
102
|
+
var requestUrl, endpoint, urls;
|
|
113
103
|
|
|
104
|
+
// Get authorizeUrl and issuer
|
|
114
105
|
urls = (0, _util.getOAuthUrls)(sdk, tokenParams);
|
|
115
106
|
endpoint = options.codeVerifier ? urls.tokenUrl : urls.authorizeUrl;
|
|
116
|
-
requestUrl = endpoint + (0, _authorize.buildAuthorizeParams)(tokenParams);
|
|
107
|
+
requestUrl = endpoint + (0, _authorize.buildAuthorizeParams)(tokenParams);
|
|
117
108
|
|
|
109
|
+
// Determine the flow type
|
|
118
110
|
var flowType;
|
|
119
|
-
|
|
120
111
|
if (tokenParams.sessionToken || tokenParams.display === null) {
|
|
121
112
|
flowType = 'IFRAME';
|
|
122
113
|
} else if (tokenParams.display === 'popup') {
|
|
123
114
|
flowType = 'POPUP';
|
|
124
115
|
} else {
|
|
125
116
|
flowType = 'IMPLICIT';
|
|
126
|
-
}
|
|
127
|
-
|
|
117
|
+
}
|
|
128
118
|
|
|
119
|
+
// Execute the flow type
|
|
129
120
|
switch (flowType) {
|
|
130
121
|
case 'IFRAME':
|
|
131
122
|
var iframePromise = (0, _util.addPostMessageListener)(sdk, options.timeout, tokenParams.state);
|
|
@@ -135,39 +126,37 @@ function getToken(sdk, options) {
|
|
|
135
126
|
}).finally(function () {
|
|
136
127
|
if (document.body.contains(iframeEl)) {
|
|
137
128
|
var _iframeEl$parentEleme;
|
|
138
|
-
|
|
139
129
|
(_iframeEl$parentEleme = iframeEl.parentElement) === null || _iframeEl$parentEleme === void 0 ? void 0 : _iframeEl$parentEleme.removeChild(iframeEl);
|
|
140
130
|
}
|
|
141
131
|
});
|
|
142
|
-
|
|
143
132
|
case 'POPUP':
|
|
144
133
|
var oauthPromise; // resolves with OAuth response
|
|
134
|
+
|
|
145
135
|
// Add listener on postMessage before window creation, so
|
|
146
136
|
// postMessage isn't triggered before we're listening
|
|
147
|
-
|
|
148
137
|
if (tokenParams.responseMode === 'okta_post_message') {
|
|
149
138
|
if (!sdk.features.isPopupPostMessageSupported()) {
|
|
150
139
|
throw new _AuthSdkError.default('This browser doesn\'t have full postMessage support');
|
|
151
140
|
}
|
|
152
|
-
|
|
153
141
|
oauthPromise = (0, _util.addPostMessageListener)(sdk, options.timeout, tokenParams.state);
|
|
154
|
-
}
|
|
155
|
-
// popupWindown can be null when popup is blocked
|
|
156
|
-
|
|
142
|
+
}
|
|
157
143
|
|
|
144
|
+
// Redirect for authorization
|
|
145
|
+
// popupWindown can be null when popup is blocked
|
|
158
146
|
if (popupWindow) {
|
|
159
147
|
popupWindow.location.assign(requestUrl);
|
|
160
|
-
}
|
|
161
|
-
|
|
148
|
+
}
|
|
162
149
|
|
|
150
|
+
// The popup may be closed without receiving an OAuth response. Setup a poller to monitor the window.
|
|
163
151
|
var popupPromise = new Promise(function (resolve, reject) {
|
|
164
152
|
var closePoller = setInterval(function () {
|
|
165
153
|
if (!popupWindow || popupWindow.closed) {
|
|
166
154
|
clearInterval(closePoller);
|
|
167
155
|
reject(new _AuthSdkError.default('Unable to parse OAuth flow response'));
|
|
168
156
|
}
|
|
169
|
-
}, 100);
|
|
157
|
+
}, 100);
|
|
170
158
|
|
|
159
|
+
// Proxy the OAuth promise results
|
|
171
160
|
oauthPromise.then(function (res) {
|
|
172
161
|
clearInterval(closePoller);
|
|
173
162
|
resolve(res);
|
|
@@ -183,7 +172,6 @@ function getToken(sdk, options) {
|
|
|
183
172
|
popupWindow.close();
|
|
184
173
|
}
|
|
185
174
|
});
|
|
186
|
-
|
|
187
175
|
default:
|
|
188
176
|
throw new _AuthSdkError.default('The full page redirect flow is not supported');
|
|
189
177
|
}
|
package/cjs/oidc/getToken.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getToken.js","names":["getToken","sdk","options","arguments","length","Promise","reject","AuthSdkError","popupWindow","undefined","prepareTokenParams","then","tokenParams","sessionTokenOverrides","prompt","responseMode","display","idpOverrides","sessionToken","Object","assign","idp","requestUrl","endpoint","urls","getOAuthUrls","codeVerifier","tokenUrl","authorizeUrl","buildAuthorizeParams","flowType","iframePromise","addPostMessageListener","timeout","state","iframeEl","loadFrame","res","handleOAuthResponse","finally","document","body","contains","parentElement","removeChild","oauthPromise","features","isPopupPostMessageSupported","location","popupPromise","resolve","closePoller","setInterval","closed","clearInterval","catch","err","close"],"sources":["../../../lib/oidc/getToken.ts"],"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 addPostMessageListener\n} from './util';\n\nimport AuthSdkError from '../errors/AuthSdkError';\n\nimport {\n OktaAuthOAuthInterface,\n TokenParams,\n PopupParams,\n OAuthResponse,\n} from './types';\n\nimport { prepareTokenParams } from './util/prepareTokenParams';\nimport { buildAuthorizeParams } from './endpoints/authorize';\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: OktaAuthOAuthInterface, 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 as OAuthResponse, 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 as OAuthResponse, 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}"],"mappings":";;;;;;AAeA;;AAMA;;AASA;;AACA;;AACA;;AA/BA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAkBC,GAAlB,EAA+CC,OAA/C,EAAmF;EACxF,IAAIC,SAAS,CAACC,MAAV,GAAmB,CAAvB,EAA0B;IACxB,OAAOC,OAAO,CAACC,MAAR,CAAe,IAAIC,qBAAJ,CAAiB,kEAAjB,CAAf,CAAP;EACD;;EAEDL,OAAO,GAAGA,OAAO,IAAI,EAArB,CALwF,CAOxF;EACA;;EACA,MAAMM,WAAW,GAAGN,OAAO,CAACM,WAA5B;EACAN,OAAO,CAACM,WAAR,GAAsBC,SAAtB;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L4B,EAK1B,GAL0B,CAA7B,CADwD,CAQxD;;UACAsC,YAAY,CACTlC,IADH,CACQ,UAAU0B,GAAV,EAAe;YACnBiB,aAAa,CAACH,WAAD,CAAb;YACAD,OAAO,CAACb,GAAD,CAAP;UACD,CAJH,EAKGkB,KALH,CAKS,UAAUC,GAAV,EAAe;YACpBF,aAAa,CAACH,WAAD,CAAb;YACA7C,MAAM,CAACkD,GAAD,CAAN;UACD,CARH;QASD,CAlBkB,CAAnB;QAoBA,OAAOP,YAAY,CAChBtC,IADI,CACC,UAAU0B,GAAV,EAAe;UACnB,OAAO,IAAAC,wCAAA,EAAoBrC,GAApB,EAAyBW,WAAzB,EAAsCyB,GAAtC,EAA4Db,IAA5D,CAAP;QACD,CAHI,EAIJe,OAJI,CAII,YAAY;UACnB,IAAI/B,WAAW,IAAI,CAACA,WAAW,CAAC6C,MAAhC,EAAwC;YACtC7C,WAAW,CAACiD,KAAZ;UACD;QACF,CARI,CAAP;;MAUF;QACE,MAAM,IAAIlD,qBAAJ,CAAiB,8CAAjB,CAAN;IAhEJ;EAkED,CA3GI,CAAP;AA4GD"}
|
|
1
|
+
{"version":3,"file":"getToken.js","names":["getToken","sdk","options","arguments","length","Promise","reject","AuthSdkError","popupWindow","undefined","prepareTokenParams","then","tokenParams","sessionTokenOverrides","prompt","responseMode","display","idpOverrides","sessionToken","Object","assign","idp","requestUrl","endpoint","urls","getOAuthUrls","codeVerifier","tokenUrl","authorizeUrl","buildAuthorizeParams","flowType","iframePromise","addPostMessageListener","timeout","state","iframeEl","loadFrame","res","handleOAuthResponse","finally","document","body","contains","parentElement","removeChild","oauthPromise","features","isPopupPostMessageSupported","location","popupPromise","resolve","closePoller","setInterval","closed","clearInterval","catch","err","close"],"sources":["../../../lib/oidc/getToken.ts"],"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 addPostMessageListener\n} from './util';\n\nimport AuthSdkError from '../errors/AuthSdkError';\n\nimport {\n OktaAuthOAuthInterface,\n TokenParams,\n PopupParams,\n OAuthResponse,\n} from './types';\n\nimport { prepareTokenParams } from './util/prepareTokenParams';\nimport { buildAuthorizeParams } from './endpoints/authorize';\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: OktaAuthOAuthInterface, 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 as OAuthResponse, 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 as OAuthResponse, 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}"],"mappings":";;;;AAeA;AAMA;AASA;AACA;AACA;AA/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAQ,CAACC,GAA2B,EAAEC,OAAkC,EAAE;EACxF,IAAIC,SAAS,CAACC,MAAM,GAAG,CAAC,EAAE;IACxB,OAAOC,OAAO,CAACC,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AM,EAAE;cACtCC,aAAa,CAACH,WAAW,CAAC;cAC1B7C,MAAM,CAAC,IAAIC,qBAAY,CAAC,qCAAqC,CAAC,CAAC;YACjE;UACF,CAAC,EAAE,GAAG,CAAC;;UAEP;UACAsC,YAAY,CACTlC,IAAI,CAAC,UAAU0B,GAAG,EAAE;YACnBiB,aAAa,CAACH,WAAW,CAAC;YAC1BD,OAAO,CAACb,GAAG,CAAC;UACd,CAAC,CAAC,CACDkB,KAAK,CAAC,UAAUC,GAAG,EAAE;YACpBF,aAAa,CAACH,WAAW,CAAC;YAC1B7C,MAAM,CAACkD,GAAG,CAAC;UACb,CAAC,CAAC;QACN,CAAC,CAAC;QAEF,OAAOP,YAAY,CAChBtC,IAAI,CAAC,UAAU0B,GAAG,EAAE;UACnB,OAAO,IAAAC,wCAAmB,EAACrC,GAAG,EAAEW,WAAW,EAAEyB,GAAG,EAAmBb,IAAI,CAAC;QAC1E,CAAC,CAAC,CACDe,OAAO,CAAC,YAAY;UACnB,IAAI/B,WAAW,IAAI,CAACA,WAAW,CAAC6C,MAAM,EAAE;YACtC7C,WAAW,CAACiD,KAAK,EAAE;UACrB;QACF,CAAC,CAAC;MAEN;QACE,MAAM,IAAIlD,qBAAY,CAAC,8CAA8C,CAAC;IAAC;EAE7E,CAAC,CAAC;AACN"}
|
package/cjs/oidc/getUserInfo.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.getUserInfo = getUserInfo;
|
|
4
|
-
|
|
5
4
|
var _util = require("../util");
|
|
6
|
-
|
|
7
5
|
var _errors = require("../errors");
|
|
8
|
-
|
|
9
6
|
var _http = require("../http");
|
|
10
|
-
|
|
11
7
|
var _types = require("./types");
|
|
12
|
-
|
|
13
8
|
/* eslint-disable complexity */
|
|
14
|
-
|
|
15
9
|
/*!
|
|
16
10
|
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
17
11
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -24,24 +18,21 @@ var _types = require("./types");
|
|
|
24
18
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
25
19
|
*
|
|
26
20
|
*/
|
|
21
|
+
|
|
27
22
|
async function getUserInfo(sdk, accessTokenObject, idTokenObject) {
|
|
28
23
|
// If token objects were not passed, attempt to read from the TokenManager
|
|
29
24
|
if (!accessTokenObject) {
|
|
30
25
|
accessTokenObject = (await sdk.tokenManager.getTokens()).accessToken;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
if (!idTokenObject) {
|
|
34
28
|
idTokenObject = (await sdk.tokenManager.getTokens()).idToken;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
if (!accessTokenObject || !(0, _types.isAccessToken)(accessTokenObject)) {
|
|
38
31
|
return Promise.reject(new _errors.AuthSdkError('getUserInfo requires an access token object'));
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
if (!idTokenObject || !(0, _types.isIDToken)(idTokenObject)) {
|
|
42
34
|
return Promise.reject(new _errors.AuthSdkError('getUserInfo requires an ID token object'));
|
|
43
35
|
}
|
|
44
|
-
|
|
45
36
|
return (0, _http.httpRequest)(sdk, {
|
|
46
37
|
url: accessTokenObject.userinfoUrl,
|
|
47
38
|
method: 'GET',
|
|
@@ -51,30 +42,25 @@ async function getUserInfo(sdk, accessTokenObject, idTokenObject) {
|
|
|
51
42
|
if (userInfo.sub === idTokenObject.claims.sub) {
|
|
52
43
|
return userInfo;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
return Promise.reject(new _errors.AuthSdkError('getUserInfo request was rejected due to token mismatch'));
|
|
56
46
|
}).catch(function (err) {
|
|
57
47
|
if (err.xhr && (err.xhr.status === 401 || err.xhr.status === 403)) {
|
|
58
48
|
var authenticateHeader;
|
|
59
|
-
|
|
60
49
|
if (err.xhr.headers && (0, _util.isFunction)(err.xhr.headers.get) && err.xhr.headers.get('WWW-Authenticate')) {
|
|
61
50
|
authenticateHeader = err.xhr.headers.get('WWW-Authenticate');
|
|
62
51
|
} else if ((0, _util.isFunction)(err.xhr.getResponseHeader)) {
|
|
63
52
|
authenticateHeader = err.xhr.getResponseHeader('WWW-Authenticate');
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
if (authenticateHeader) {
|
|
67
55
|
var errorMatches = authenticateHeader.match(/error="(.*?)"/) || [];
|
|
68
56
|
var errorDescriptionMatches = authenticateHeader.match(/error_description="(.*?)"/) || [];
|
|
69
57
|
var error = errorMatches[1];
|
|
70
58
|
var errorDescription = errorDescriptionMatches[1];
|
|
71
|
-
|
|
72
59
|
if (error && errorDescription) {
|
|
73
60
|
err = new _errors.OAuthError(error, errorDescription);
|
|
74
61
|
}
|
|
75
62
|
}
|
|
76
63
|
}
|
|
77
|
-
|
|
78
64
|
throw err;
|
|
79
65
|
});
|
|
80
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserInfo.js","names":["getUserInfo","sdk","accessTokenObject","idTokenObject","tokenManager","getTokens","accessToken","idToken","isAccessToken","Promise","reject","AuthSdkError","isIDToken","httpRequest","url","userinfoUrl","method","then","userInfo","sub","claims","catch","err","xhr","status","authenticateHeader","headers","isFunction","get","getResponseHeader","errorMatches","match","errorDescriptionMatches","error","errorDescription","OAuthError"],"sources":["../../../lib/oidc/getUserInfo.ts"],"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, CustomUserClaims } from './types';\n\nexport async function getUserInfo<T extends CustomUserClaims = CustomUserClaims>(\n sdk, accessTokenObject: AccessToken,\n idTokenObject: IDToken\n): Promise<UserClaims<T>> {\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getUserInfo.js","names":["getUserInfo","sdk","accessTokenObject","idTokenObject","tokenManager","getTokens","accessToken","idToken","isAccessToken","Promise","reject","AuthSdkError","isIDToken","httpRequest","url","userinfoUrl","method","then","userInfo","sub","claims","catch","err","xhr","status","authenticateHeader","headers","isFunction","get","getResponseHeader","errorMatches","match","errorDescriptionMatches","error","errorDescription","OAuthError"],"sources":["../../../lib/oidc/getUserInfo.ts"],"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, CustomUserClaims } from './types';\n\nexport async function getUserInfo<T extends CustomUserClaims = CustomUserClaims>(\n sdk, accessTokenObject: AccessToken,\n idTokenObject: IDToken\n): Promise<UserClaims<T>> {\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"],"mappings":";;;AAaA;AACA;AACA;AACA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,eAAeA,WAAW,CAC/BC,GAAG,EAAEC,iBAA8B,EACnCC,aAAsB,EACE;EACxB;EACA,IAAI,CAACD,iBAAiB,EAAE;IACtBA,iBAAiB,GAAG,CAAC,MAAMD,GAAG,CAACG,YAAY,CAACC,SAAS,EAAE,EAAEC,WAA0B;EACrF;EACA,IAAI,CAACH,aAAa,EAAE;IAClBA,aAAa,GAAG,CAAC,MAAMF,GAAG,CAACG,YAAY,CAACC,SAAS,EAAE,EAAEE,OAAkB;EACzE;EAEA,IAAI,CAACL,iBAAiB,IAAI,CAAC,IAAAM,oBAAa,EAACN,iBAAiB,CAAC,EAAE;IAC3D,OAAOO,OAAO,CAACC,MAAM,CAAC,IAAIC,oBAAY,CAAC,6CAA6C,CAAC,CAAC;EACxF;EAEA,IAAI,CAACR,aAAa,IAAI,CAAC,IAAAS,gBAAS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ACM,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE;QAClE,IAAIC,uBAAuB,GAAGP,kBAAkB,CAACM,KAAK,CAAC,2BAA2B,CAAC,IAAI,EAAE;QACzF,IAAIE,KAAK,GAAGH,YAAY,CAAC,CAAC,CAAC;QAC3B,IAAII,gBAAgB,GAAGF,uBAAuB,CAAC,CAAC,CAAC;QACjD,IAAIC,KAAK,IAAIC,gBAAgB,EAAE;UAC7BZ,GAAG,GAAG,IAAIa,kBAAU,CAACF,KAAK,EAAEC,gBAAgB,CAAC;QAC/C;MACF;IACF;IACA,MAAMZ,GAAG;EACX,CAAC,CAAC;AACN"}
|
package/cjs/oidc/getWithPopup.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.getWithPopup = getWithPopup;
|
|
4
|
-
|
|
5
4
|
var _errors = require("../errors");
|
|
6
|
-
|
|
7
5
|
var _util = require("../util");
|
|
8
|
-
|
|
9
6
|
var _getToken = require("./getToken");
|
|
10
|
-
|
|
11
7
|
var _util2 = require("./util");
|
|
12
|
-
|
|
13
8
|
/*!
|
|
14
9
|
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
15
10
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -22,14 +17,15 @@ var _util2 = require("./util");
|
|
|
22
17
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
23
18
|
*
|
|
24
19
|
*/
|
|
20
|
+
|
|
25
21
|
function getWithPopup(sdk, options) {
|
|
26
22
|
if (arguments.length > 2) {
|
|
27
23
|
return Promise.reject(new _errors.AuthSdkError('As of version 3.0, "getWithPopup" takes only a single set of options'));
|
|
28
|
-
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// some browsers (safari, firefox) block popup if it's initialed from an async process
|
|
29
27
|
// here we create the popup window immediately after user interaction
|
|
30
28
|
// then redirect to the /authorize endpoint when the requestUrl is available
|
|
31
|
-
|
|
32
|
-
|
|
33
29
|
const popupWindow = (0, _util2.loadPopup)('/', options);
|
|
34
30
|
options = (0, _util.clone)(options) || {};
|
|
35
31
|
Object.assign(options, {
|