@okta/okta-auth-js 5.11.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/README.md +63 -29
- package/cjs/AuthStateManager.js +15 -6
- package/cjs/AuthStateManager.js.map +1 -1
- package/cjs/OktaAuth.js +168 -108
- package/cjs/OktaAuth.js.map +1 -1
- package/cjs/OktaUserAgent.js +2 -2
- package/cjs/OktaUserAgent.js.map +1 -1
- package/cjs/PromiseQueue.js +11 -2
- package/cjs/PromiseQueue.js.map +1 -1
- package/cjs/SavedObject.js +4 -2
- package/cjs/SavedObject.js.map +1 -1
- package/cjs/ServiceManager.js +195 -0
- package/cjs/ServiceManager.js.map +1 -0
- package/cjs/StorageManager.js +16 -9
- package/cjs/StorageManager.js.map +1 -1
- package/cjs/TokenManager.js +42 -34
- package/cjs/TokenManager.js.map +1 -1
- package/cjs/TransactionManager.js +26 -7
- package/cjs/TransactionManager.js.map +1 -1
- package/cjs/browser/browserStorage.js +36 -20
- package/cjs/browser/browserStorage.js.map +1 -1
- package/cjs/browser/fingerprint.js +12 -4
- package/cjs/browser/fingerprint.js.map +1 -1
- package/cjs/builderUtil.js +7 -19
- package/cjs/builderUtil.js.map +1 -1
- package/cjs/clock.js +5 -1
- package/cjs/clock.js.map +1 -1
- package/cjs/crypto/base64.js +18 -0
- package/cjs/crypto/base64.js.map +1 -1
- package/cjs/crypto/index.js +6 -4
- package/cjs/crypto/index.js.map +1 -1
- package/cjs/crypto/node.js +19 -13
- package/cjs/crypto/node.js.map +1 -1
- package/cjs/crypto/oidcHash.js +5 -1
- package/cjs/crypto/oidcHash.js.map +1 -1
- package/cjs/crypto/webauthn.js +101 -0
- package/cjs/crypto/webauthn.js.map +1 -0
- package/cjs/crypto/webcrypto.js +3 -1
- package/cjs/crypto/webcrypto.js.map +1 -1
- package/cjs/errors/AuthApiError.js +1 -1
- package/cjs/errors/AuthPollStopError.js +1 -1
- package/cjs/errors/AuthSdkError.js +1 -1
- package/cjs/errors/CustomError.js +5 -1
- package/cjs/errors/CustomError.js.map +1 -1
- package/cjs/errors/OAuthError.js +1 -1
- package/cjs/errors/index.js +1 -1
- package/cjs/features.js +9 -3
- package/cjs/features.js.map +1 -1
- package/cjs/fetch/fetchRequest.js +19 -6
- package/cjs/fetch/fetchRequest.js.map +1 -1
- package/cjs/http/headers.js.map +1 -1
- package/cjs/http/index.js +4 -2
- package/cjs/http/index.js.map +1 -1
- package/cjs/http/request.js +11 -5
- package/cjs/http/request.js.map +1 -1
- package/cjs/idx/authenticate.js +8 -5
- package/cjs/idx/authenticate.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +1 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js +2 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +2 -2
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnEnrollment.js +46 -0
- package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -0
- package/cjs/idx/authenticator/WebauthnVerification.js +55 -0
- package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -0
- package/cjs/idx/authenticator/getAuthenticator.js +17 -6
- package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/index.js +34 -6
- package/cjs/idx/authenticator/index.js.map +1 -1
- package/cjs/idx/cancel.js.map +1 -1
- package/cjs/idx/emailVerify.js +73 -0
- package/cjs/idx/emailVerify.js.map +1 -0
- package/cjs/idx/flow/AccountUnlockFlow.js +30 -0
- package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -0
- package/cjs/idx/flow/FlowSpecification.js +24 -4
- package/cjs/idx/flow/FlowSpecification.js.map +1 -1
- package/cjs/idx/flow/PasswordRecoveryFlow.js +4 -1
- package/cjs/idx/flow/PasswordRecoveryFlow.js.map +1 -1
- package/cjs/idx/flow/RegistrationFlow.js +2 -0
- package/cjs/idx/flow/RegistrationFlow.js.map +1 -1
- package/cjs/idx/flow/index.js +20 -5
- package/cjs/idx/flow/index.js.map +1 -1
- package/cjs/idx/handleInteractionCodeRedirect.js +6 -1
- package/cjs/idx/handleInteractionCodeRedirect.js.map +1 -1
- package/cjs/idx/headers.js +21 -5
- package/cjs/idx/headers.js.map +1 -1
- package/cjs/idx/idx-js/client.js +91 -0
- package/cjs/idx/idx-js/client.js.map +1 -0
- package/cjs/idx/idx-js/index.js +162 -0
- package/cjs/idx/idx-js/index.js.map +1 -0
- package/cjs/idx/idx-js/interact.js +83 -0
- package/cjs/idx/idx-js/interact.js.map +1 -0
- package/cjs/idx/idx-js/introspect.js +58 -0
- package/cjs/idx/idx-js/introspect.js.map +1 -0
- package/cjs/idx/idx-js/parsers.js +41 -0
- package/cjs/idx/idx-js/parsers.js.map +1 -0
- package/cjs/idx/idx-js/util.js +34 -0
- package/cjs/idx/idx-js/util.js.map +1 -0
- package/cjs/idx/idx-js/v1/actionParser.js +90 -0
- package/cjs/idx/idx-js/v1/actionParser.js.map +1 -0
- package/cjs/idx/idx-js/v1/generateIdxAction.js +117 -0
- package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -0
- package/cjs/idx/idx-js/v1/idxResponseParser.js +137 -0
- package/cjs/idx/idx-js/v1/idxResponseParser.js.map +1 -0
- package/cjs/idx/idx-js/v1/makeIdxState.js +64 -0
- package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -0
- package/cjs/idx/idx-js/v1/parsers.js +24 -0
- package/cjs/idx/idx-js/v1/parsers.js.map +1 -0
- package/cjs/idx/idx-js/v1/remediationParser.js +32 -0
- package/cjs/idx/idx-js/v1/remediationParser.js.map +1 -0
- package/cjs/idx/index.js +121 -109
- package/cjs/idx/index.js.map +1 -1
- package/cjs/idx/interact.js +53 -36
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/introspect.js +17 -19
- package/cjs/idx/introspect.js.map +1 -1
- package/cjs/idx/poll.js +13 -3
- package/cjs/idx/poll.js.map +1 -1
- package/cjs/idx/proceed.js +4 -7
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/recoverPassword.js +1 -1
- package/cjs/idx/recoverPassword.js.map +1 -1
- package/cjs/idx/register.js +11 -16
- package/cjs/idx/register.js.map +1 -1
- package/cjs/idx/remediate.js +74 -27
- package/cjs/idx/remediate.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +12 -4
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +52 -9
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +31 -13
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +67 -31
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +46 -30
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +16 -4
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengeAuthenticator.js +2 -2
- package/cjs/idx/remediators/ChallengeAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengePoll.js +2 -2
- package/cjs/idx/remediators/EnrollAuthenticator.js +2 -2
- package/cjs/idx/remediators/EnrollAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/EnrollPoll.js +18 -9
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
- package/cjs/idx/remediators/EnrollProfile.js +24 -9
- package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/EnrollmentChannelData.js +96 -0
- package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -0
- package/cjs/idx/remediators/Identify.js +5 -3
- package/cjs/idx/remediators/Identify.js.map +1 -1
- package/cjs/idx/remediators/ReEnrollAuthenticator.js +6 -3
- package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/RedirectIdp.js +2 -2
- package/cjs/idx/remediators/ResetAuthenticator.js +2 -2
- package/cjs/idx/remediators/ResetAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +7 -5
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +2 -2
- package/cjs/idx/remediators/SelectAuthenticatorEnroll.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +72 -0
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -0
- package/cjs/idx/remediators/SelectEnrollProfile.js +2 -2
- package/cjs/idx/remediators/SelectEnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/SelectEnrollmentChannel.js +86 -0
- package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -0
- package/cjs/idx/remediators/Skip.js +5 -3
- package/cjs/idx/remediators/Skip.js.map +1 -1
- package/cjs/idx/remediators/index.js +57 -16
- package/cjs/idx/remediators/index.js.map +1 -1
- package/cjs/idx/remediators/util.js +18 -3
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +145 -49
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/startTransaction.js +4 -2
- package/cjs/idx/startTransaction.js.map +1 -1
- package/cjs/idx/transactionMeta.js +82 -69
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/types/index.js +59 -7
- package/cjs/idx/types/index.js.map +1 -1
- package/cjs/idx/unlockAccount.js +48 -0
- package/cjs/idx/unlockAccount.js.map +1 -0
- package/cjs/index.js +33 -13
- package/cjs/index.js.map +1 -1
- package/cjs/oidc/endpoints/authorize.js +10 -2
- package/cjs/oidc/endpoints/authorize.js.map +1 -1
- package/cjs/oidc/endpoints/index.js +5 -3
- package/cjs/oidc/endpoints/index.js.map +1 -1
- package/cjs/oidc/endpoints/token.js +16 -3
- package/cjs/oidc/endpoints/token.js.map +1 -1
- package/cjs/oidc/endpoints/well-known.js +7 -3
- package/cjs/oidc/endpoints/well-known.js.map +1 -1
- package/cjs/oidc/exchangeCodeForTokens.js +12 -4
- package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
- package/cjs/oidc/getToken.js +12 -6
- package/cjs/oidc/getToken.js.map +1 -1
- package/cjs/oidc/getUserInfo.js +7 -3
- package/cjs/oidc/getUserInfo.js.map +1 -1
- package/cjs/oidc/getWithPopup.js +8 -2
- package/cjs/oidc/getWithPopup.js.map +1 -1
- package/cjs/oidc/getWithRedirect.js +15 -38
- package/cjs/oidc/getWithRedirect.js.map +1 -1
- package/cjs/oidc/getWithoutPrompt.js +8 -2
- package/cjs/oidc/getWithoutPrompt.js.map +1 -1
- package/cjs/oidc/handleOAuthResponse.js +87 -87
- package/cjs/oidc/handleOAuthResponse.js.map +1 -1
- package/cjs/oidc/index.js +4 -2
- package/cjs/oidc/index.js.map +1 -1
- package/cjs/oidc/parseFromUrl.js +9 -3
- package/cjs/oidc/parseFromUrl.js.map +1 -1
- package/cjs/oidc/renewToken.js.map +1 -1
- package/cjs/oidc/renewTokens.js +6 -2
- package/cjs/oidc/renewTokens.js.map +1 -1
- package/cjs/oidc/renewTokensWithRefresh.js +5 -1
- package/cjs/oidc/renewTokensWithRefresh.js.map +1 -1
- package/cjs/oidc/revokeToken.js +34 -31
- package/cjs/oidc/revokeToken.js.map +1 -1
- package/cjs/oidc/util/browser.js +5 -1
- package/cjs/oidc/util/browser.js.map +1 -1
- package/cjs/oidc/util/defaultTokenParams.js.map +1 -1
- package/cjs/oidc/util/errors.js.map +1 -1
- package/cjs/oidc/util/index.js +27 -11
- package/cjs/oidc/util/index.js.map +1 -1
- package/cjs/oidc/util/loginRedirect.js +10 -1
- package/cjs/oidc/util/loginRedirect.js.map +1 -1
- package/cjs/oidc/util/oauth.js +4 -2
- package/cjs/oidc/util/oauth.js.map +1 -1
- package/cjs/oidc/util/oauthMeta.js +36 -0
- package/cjs/oidc/util/oauthMeta.js.map +1 -0
- package/cjs/oidc/util/pkce.js +11 -3
- package/cjs/oidc/util/pkce.js.map +1 -1
- package/cjs/oidc/util/prepareTokenParams.js +62 -39
- package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
- package/cjs/oidc/util/validateClaims.js +3 -1
- package/cjs/oidc/util/validateClaims.js.map +1 -1
- package/cjs/oidc/verifyToken.js +13 -4
- package/cjs/oidc/verifyToken.js.map +1 -1
- package/cjs/options/browser.js +81 -0
- package/cjs/options/browser.js.map +1 -0
- package/cjs/options/index.js +94 -0
- package/cjs/options/index.js.map +1 -0
- package/cjs/options/node.js +46 -0
- package/cjs/options/node.js.map +1 -0
- package/cjs/server/serverStorage.js +9 -5
- package/cjs/server/serverStorage.js.map +1 -1
- package/cjs/services/AutoRenewService.js +94 -0
- package/cjs/services/AutoRenewService.js.map +1 -0
- package/cjs/services/SyncStorageService.js +93 -0
- package/cjs/services/SyncStorageService.js.map +1 -0
- package/cjs/services/index.js +30 -0
- package/cjs/services/index.js.map +1 -0
- package/cjs/tx/AuthTransaction.js +18 -9
- package/cjs/tx/AuthTransaction.js.map +1 -1
- package/cjs/tx/TransactionState.js +0 -17
- package/cjs/tx/TransactionState.js.map +1 -1
- package/cjs/tx/api.js +11 -6
- package/cjs/tx/api.js.map +1 -1
- package/cjs/tx/index.js +7 -5
- package/cjs/tx/index.js.map +1 -1
- package/cjs/tx/poll.js +6 -4
- package/cjs/tx/poll.js.map +1 -1
- package/cjs/tx/util.js +5 -1
- package/cjs/tx/util.js.map +1 -1
- package/cjs/types/Service.js +2 -0
- package/cjs/types/Service.js.map +1 -0
- package/cjs/types/Transaction.js +10 -2
- package/cjs/types/Transaction.js.map +1 -1
- package/cjs/types/index.js +29 -14
- package/cjs/types/index.js.map +1 -1
- package/cjs/util/index.js +7 -18
- package/cjs/util/index.js.map +1 -1
- package/cjs/util/misc.js +5 -1
- package/cjs/util/misc.js.map +1 -1
- package/cjs/util/object.js +16 -6
- package/cjs/util/object.js.map +1 -1
- package/cjs/util/sharedStorage.js +5 -1
- package/cjs/util/sharedStorage.js.map +1 -1
- package/cjs/util/url.js.map +1 -1
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.LICENSE.txt +0 -20
- package/dist/okta-auth-js.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/dist/okta-auth-js.umd.js +1 -1
- package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -19
- package/dist/okta-auth-js.umd.js.map +1 -1
- package/esm/{index.js → esm.browser.js} +3283 -2698
- package/esm/esm.browser.js.map +1 -0
- package/esm/esm.node.mjs +9277 -0
- package/esm/esm.node.mjs.map +1 -0
- package/lib/AuthStateManager.d.ts +2 -5
- package/lib/OktaAuth.d.ts +14 -16
- package/lib/ServiceManager.d.ts +38 -0
- package/lib/StorageManager.d.ts +2 -2
- package/lib/TokenManager.d.ts +4 -5
- package/lib/TransactionManager.d.ts +4 -3
- package/lib/browser/fingerprint.d.ts +2 -3
- package/lib/builderUtil.d.ts +1 -2
- package/lib/crypto/base64.d.ts +2 -0
- package/lib/crypto/browser.d.ts +1 -1
- package/lib/crypto/webauthn.d.ts +25 -0
- package/lib/features.d.ts +1 -1
- package/lib/http/headers.d.ts +2 -2
- package/lib/http/request.d.ts +4 -4
- package/lib/idx/authenticate.d.ts +2 -2
- package/lib/idx/authenticator/Authenticator.d.ts +4 -5
- package/lib/idx/authenticator/OktaPassword.d.ts +7 -9
- package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +9 -8
- package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +7 -7
- package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +6 -2
- package/lib/idx/authenticator/WebauthnEnrollment.d.ts +16 -0
- package/lib/idx/authenticator/WebauthnVerification.d.ts +17 -0
- package/lib/idx/authenticator/getAuthenticator.d.ts +1 -1
- package/lib/idx/authenticator/index.d.ts +9 -0
- package/lib/idx/cancel.d.ts +2 -2
- package/lib/idx/emailVerify.d.ts +26 -0
- package/lib/{util/emailVerify.d.ts → idx/flow/AccountUnlockFlow.d.ts} +2 -6
- package/lib/idx/flow/FlowSpecification.d.ts +3 -2
- package/lib/idx/flow/index.d.ts +1 -0
- package/lib/idx/headers.d.ts +3 -2
- package/lib/idx/idx-js/client.d.ts +36 -0
- package/lib/idx/idx-js/index.d.ts +51 -0
- package/lib/idx/idx-js/interact.d.ts +25 -0
- package/lib/idx/idx-js/introspect.d.ts +20 -0
- package/lib/idx/idx-js/parsers.d.ts +15 -0
- package/lib/idx/idx-js/util.d.ts +12 -0
- package/lib/idx/idx-js/v1/actionParser.d.ts +16 -0
- package/lib/idx/idx-js/v1/generateIdxAction.d.ts +13 -0
- package/lib/idx/idx-js/v1/idxResponseParser.d.ts +20 -0
- package/lib/idx/idx-js/v1/makeIdxState.d.ts +13 -0
- package/lib/idx/idx-js/v1/parsers.d.ts +16 -0
- package/lib/idx/idx-js/v1/remediationParser.d.ts +12 -0
- package/lib/idx/index.d.ts +12 -10
- package/lib/idx/interact.d.ts +7 -13
- package/lib/idx/introspect.d.ts +4 -3
- package/lib/idx/poll.d.ts +2 -2
- package/lib/idx/proceed.d.ts +8 -5
- package/lib/idx/recoverPassword.d.ts +2 -2
- package/lib/idx/register.d.ts +2 -2
- package/lib/idx/remediate.d.ts +10 -4
- package/lib/idx/remediators/AuthenticatorEnrollmentData.d.ts +3 -3
- package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +5 -5
- package/lib/idx/remediators/Base/AuthenticatorData.d.ts +10 -10
- package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +10 -7
- package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +8 -12
- package/lib/idx/remediators/EnrollProfile.d.ts +1 -1
- package/lib/idx/remediators/EnrollmentChannelData.d.ts +54 -0
- package/lib/idx/remediators/Identify.d.ts +2 -2
- package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -2
- package/lib/idx/remediators/RedirectIdp.d.ts +3 -3
- package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +38 -0
- package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +40 -0
- package/lib/idx/remediators/index.d.ts +3 -0
- package/lib/idx/remediators/util.d.ts +2 -2
- package/lib/idx/run.d.ts +5 -3
- package/lib/idx/startTransaction.d.ts +3 -2
- package/lib/idx/transactionMeta.d.ts +10 -31
- package/lib/idx/types/FlowIdentifier.d.ts +1 -1
- package/lib/idx/types/idx-js.d.ts +44 -1
- package/lib/idx/types/index.d.ts +36 -9
- package/lib/idx/unlockAccount.d.ts +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/oidc/endpoints/well-known.d.ts +3 -3
- package/lib/oidc/exchangeCodeForTokens.d.ts +14 -2
- package/lib/oidc/getToken.d.ts +2 -2
- package/lib/oidc/getWithPopup.d.ts +2 -2
- package/lib/oidc/getWithRedirect.d.ts +2 -2
- package/lib/oidc/getWithoutPrompt.d.ts +2 -2
- package/lib/oidc/handleOAuthResponse.d.ts +2 -2
- package/lib/oidc/parseFromUrl.d.ts +1 -1
- package/lib/oidc/renewToken.d.ts +2 -2
- package/lib/oidc/renewTokens.d.ts +1 -1
- package/lib/oidc/renewTokensWithRefresh.d.ts +2 -2
- package/lib/oidc/revokeToken.d.ts +2 -2
- package/lib/oidc/util/browser.d.ts +3 -3
- package/lib/oidc/util/defaultTokenParams.d.ts +2 -2
- package/lib/oidc/util/errors.d.ts +2 -2
- package/lib/oidc/util/index.d.ts +1 -0
- package/lib/oidc/util/loginRedirect.d.ts +4 -4
- package/lib/oidc/util/oauth.d.ts +4 -11
- package/lib/oidc/util/oauthMeta.d.ts +2 -0
- package/lib/oidc/util/prepareTokenParams.d.ts +5 -2
- package/lib/oidc/util/validateClaims.d.ts +2 -2
- package/lib/oidc/verifyToken.d.ts +2 -2
- package/lib/options/browser.d.ts +16 -0
- package/lib/{options.d.ts → options/index.d.ts} +1 -1
- package/lib/options/node.d.ts +16 -0
- package/lib/server/serverStorage.d.ts +1 -1
- package/lib/services/AutoRenewService.d.ts +27 -0
- package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
- package/lib/services/index.d.ts +13 -0
- package/lib/tx/AuthTransaction.d.ts +2 -2
- package/lib/tx/TransactionState.d.ts +11 -1
- package/lib/tx/api.d.ts +6 -6
- package/lib/types/OktaAuthOptions.d.ts +11 -8
- package/lib/types/Service.d.ts +23 -0
- package/lib/types/Storage.d.ts +3 -3
- package/lib/types/Transaction.d.ts +10 -7
- package/lib/types/UserClaims.d.ts +3 -3
- package/lib/types/api.d.ts +49 -22
- package/lib/types/index.d.ts +1 -1
- package/lib/util/console.d.ts +1 -1
- package/lib/util/index.d.ts +0 -1
- package/lib/util/sharedStorage.d.ts +1 -1
- package/lib/util/types.d.ts +1 -1
- package/lib/util/url.d.ts +2 -2
- package/package.json +30 -13
- package/polyfill/index.js +1 -0
- package/cjs/options.js +0 -154
- package/cjs/options.js.map +0 -1
- package/cjs/services/TokenService.js +0 -108
- package/cjs/services/TokenService.js.map +0 -1
- package/cjs/util/emailVerify.js +0 -28
- package/cjs/util/emailVerify.js.map +0 -1
- package/esm/index.js.map +0 -1
package/cjs/OktaAuth.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
|
4
|
+
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
6
|
+
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
8
|
|
|
5
9
|
exports.default = void 0;
|
|
6
10
|
|
|
11
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
12
|
+
|
|
13
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
+
|
|
15
|
+
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
16
|
+
|
|
17
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
18
|
+
|
|
7
19
|
var constants = _interopRequireWildcard(require("./constants"));
|
|
8
20
|
|
|
9
21
|
var _tx = require("./tx");
|
|
@@ -16,14 +28,18 @@ var _oidc = require("./oidc");
|
|
|
16
28
|
|
|
17
29
|
var features = _interopRequireWildcard(require("./features"));
|
|
18
30
|
|
|
31
|
+
var crypto = _interopRequireWildcard(require("./crypto"));
|
|
32
|
+
|
|
33
|
+
var webauthn = _interopRequireWildcard(require("./crypto/webauthn"));
|
|
34
|
+
|
|
19
35
|
var _browserStorage = _interopRequireDefault(require("./browser/browserStorage"));
|
|
20
36
|
|
|
21
37
|
var _util = require("./util");
|
|
22
38
|
|
|
23
|
-
var _builderUtil = require("./builderUtil");
|
|
24
|
-
|
|
25
39
|
var _TokenManager = require("./TokenManager");
|
|
26
40
|
|
|
41
|
+
var _ServiceManager = require("./ServiceManager");
|
|
42
|
+
|
|
27
43
|
var _http = require("./http");
|
|
28
44
|
|
|
29
45
|
var _PromiseQueue = _interopRequireDefault(require("./PromiseQueue"));
|
|
@@ -32,7 +48,7 @@ var _fingerprint = _interopRequireDefault(require("./browser/fingerprint"));
|
|
|
32
48
|
|
|
33
49
|
var _AuthStateManager = require("./AuthStateManager");
|
|
34
50
|
|
|
35
|
-
var _StorageManager =
|
|
51
|
+
var _StorageManager = require("./StorageManager");
|
|
36
52
|
|
|
37
53
|
var _TransactionManager = _interopRequireDefault(require("./TransactionManager"));
|
|
38
54
|
|
|
@@ -46,9 +62,13 @@ var _OktaUserAgent = require("./OktaUserAgent");
|
|
|
46
62
|
|
|
47
63
|
var _parseFromUrl = require("./oidc/parseFromUrl");
|
|
48
64
|
|
|
49
|
-
|
|
65
|
+
var _transactionMeta = require("./idx/transactionMeta");
|
|
66
|
+
|
|
67
|
+
var _tinyEmitter = _interopRequireDefault(require("tiny-emitter"));
|
|
68
|
+
|
|
69
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
50
70
|
|
|
51
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty &&
|
|
71
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
52
72
|
|
|
53
73
|
/* eslint-disable max-statements */
|
|
54
74
|
|
|
@@ -66,32 +86,29 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
66
86
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
67
87
|
*/
|
|
68
88
|
|
|
69
|
-
/*
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const Emitter = require('tiny-emitter');
|
|
73
|
-
|
|
89
|
+
/* global window */
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
// Do not use this type in code, so it won't be emitted in the declaration output
|
|
74
92
|
class OktaAuth {
|
|
75
|
-
// keep this field to compatible with released downstream SDK versions
|
|
76
|
-
// TODO: remove in version 6
|
|
77
|
-
// JIRA: https://oktainc.atlassian.net/browse/OKTA-419417
|
|
78
93
|
constructor(args) {
|
|
79
|
-
const options = this.options = (0, _options.buildOptions)(args);
|
|
80
|
-
|
|
81
|
-
this.
|
|
94
|
+
const options = this.options = (0, _options.buildOptions)(args); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
95
|
+
|
|
96
|
+
this.storageManager = new _StorageManager.StorageManager(options.storageManager, options.cookies, options.storageUtil);
|
|
97
|
+
this.transactionManager = new _TransactionManager.default((0, _assign.default)({
|
|
82
98
|
storageManager: this.storageManager
|
|
83
99
|
}, options.transactionManager));
|
|
84
100
|
this._oktaUserAgent = new _OktaUserAgent.OktaUserAgent();
|
|
85
101
|
this.tx = {
|
|
86
102
|
status: _tx.transactionStatus.bind(null, this),
|
|
87
103
|
resume: _tx.resumeTransaction.bind(null, this),
|
|
88
|
-
exists:
|
|
104
|
+
exists: (0, _assign.default)(_tx.transactionExists.bind(null, this), {
|
|
89
105
|
_get: name => {
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
107
|
const storage = options.storageUtil.storage;
|
|
91
108
|
return storage.get(name);
|
|
92
109
|
}
|
|
93
110
|
}),
|
|
94
|
-
introspect: _tx.
|
|
111
|
+
introspect: _tx.introspectAuthn.bind(null, this)
|
|
95
112
|
};
|
|
96
113
|
this.pkce = {
|
|
97
114
|
DEFAULT_CODE_CHALLENGE_METHOD: _pkce.default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
@@ -99,7 +116,7 @@ class OktaAuth {
|
|
|
99
116
|
computeChallenge: _pkce.default.computeChallenge
|
|
100
117
|
}; // Add shims for compatibility, these will be removed in next major version. OKTA-362589
|
|
101
118
|
|
|
102
|
-
|
|
119
|
+
(0, _assign.default)(this.options.storageUtil, {
|
|
103
120
|
getPKCEStorage: this.storageManager.getLegacyPKCEStorage.bind(this.storageManager),
|
|
104
121
|
getHttpCache: this.storageManager.getHttpCache.bind(this.storageManager)
|
|
105
122
|
});
|
|
@@ -108,13 +125,10 @@ class OktaAuth {
|
|
|
108
125
|
};
|
|
109
126
|
|
|
110
127
|
if ((0, features.isBrowser)()) {
|
|
111
|
-
this.options =
|
|
128
|
+
this.options = (0, _assign.default)(this.options, {
|
|
112
129
|
redirectUri: (0, _util.toAbsoluteUrl)(args.redirectUri, window.location.origin) // allow relative URIs
|
|
113
130
|
|
|
114
131
|
});
|
|
115
|
-
this.userAgent = (0, _builderUtil.getUserAgent)(args, `okta-auth-js/${"5.11.0"}`);
|
|
116
|
-
} else {
|
|
117
|
-
this.userAgent = (0, _builderUtil.getUserAgent)(args, `okta-auth-js-server/${"5.11.0"}`);
|
|
118
132
|
} // Digital clocks will drift over time, so the server
|
|
119
133
|
// can misalign with the time reported by the browser.
|
|
120
134
|
// The maxClockSkew allows relaxing the time-based
|
|
@@ -142,13 +156,42 @@ class OktaAuth {
|
|
|
142
156
|
setCookieAndRedirect: _session.setCookieAndRedirect.bind(null, this)
|
|
143
157
|
};
|
|
144
158
|
this._tokenQueue = new _PromiseQueue.default();
|
|
159
|
+
|
|
160
|
+
const useQueue = method => {
|
|
161
|
+
return _PromiseQueue.default.prototype.push.bind(this._tokenQueue, method, null);
|
|
162
|
+
}; // eslint-disable-next-line max-len
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
const getWithRedirectFn = useQueue(_oidc.getWithRedirect.bind(null, this));
|
|
166
|
+
const getWithRedirectApi = (0, _assign.default)(getWithRedirectFn, {
|
|
167
|
+
// This is exposed so we can set window.location in our tests
|
|
168
|
+
_setLocation: function (url) {
|
|
169
|
+
window.location = url;
|
|
170
|
+
}
|
|
171
|
+
}); // eslint-disable-next-line max-len
|
|
172
|
+
|
|
173
|
+
const parseFromUrlFn = useQueue(_oidc.parseFromUrl.bind(null, this));
|
|
174
|
+
const parseFromUrlApi = (0, _assign.default)(parseFromUrlFn, {
|
|
175
|
+
// This is exposed so we can mock getting window.history in our tests
|
|
176
|
+
_getHistory: function () {
|
|
177
|
+
return window.history;
|
|
178
|
+
},
|
|
179
|
+
// This is exposed so we can mock getting window.location in our tests
|
|
180
|
+
_getLocation: function () {
|
|
181
|
+
return window.location;
|
|
182
|
+
},
|
|
183
|
+
// This is exposed so we can mock getting window.document in our tests
|
|
184
|
+
_getDocument: function () {
|
|
185
|
+
return window.document;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
145
188
|
this.token = {
|
|
146
189
|
prepareTokenParams: _oidc.prepareTokenParams.bind(null, this),
|
|
147
190
|
exchangeCodeForTokens: _oidc.exchangeCodeForTokens.bind(null, this),
|
|
148
191
|
getWithoutPrompt: _oidc.getWithoutPrompt.bind(null, this),
|
|
149
192
|
getWithPopup: _oidc.getWithPopup.bind(null, this),
|
|
150
|
-
getWithRedirect:
|
|
151
|
-
parseFromUrl:
|
|
193
|
+
getWithRedirect: getWithRedirectApi,
|
|
194
|
+
parseFromUrl: parseFromUrlApi,
|
|
152
195
|
decode: _oidc.decodeToken,
|
|
153
196
|
revoke: _oidc.revokeToken.bind(null, this),
|
|
154
197
|
renew: _oidc.renewToken.bind(null, this),
|
|
@@ -159,55 +202,57 @@ class OktaAuth {
|
|
|
159
202
|
isLoginRedirect: _oidc.isLoginRedirect.bind(null, this)
|
|
160
203
|
}; // Wrap all async token API methods using MethodQueue to avoid issues with concurrency
|
|
161
204
|
|
|
162
|
-
const syncMethods = [
|
|
163
|
-
|
|
164
|
-
|
|
205
|
+
const syncMethods = [// sync methods
|
|
206
|
+
'decode', 'isLoginRedirect', // already bound
|
|
207
|
+
'getWithRedirect', 'parseFromUrl'];
|
|
208
|
+
(0, _keys.default)(this.token).forEach(key => {
|
|
209
|
+
if ((0, _indexOf.default)(syncMethods).call(syncMethods, key) >= 0) {
|
|
165
210
|
// sync methods should not be wrapped
|
|
166
211
|
return;
|
|
167
212
|
}
|
|
168
213
|
|
|
169
214
|
var method = this.token[key];
|
|
170
215
|
this.token[key] = _PromiseQueue.default.prototype.push.bind(this._tokenQueue, method, null);
|
|
171
|
-
});
|
|
172
|
-
Object.assign(this.token.getWithRedirect, {
|
|
173
|
-
// This is exposed so we can set window.location in our tests
|
|
174
|
-
_setLocation: function (url) {
|
|
175
|
-
window.location = url;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
Object.assign(this.token.parseFromUrl, {
|
|
179
|
-
// This is exposed so we can mock getting window.history in our tests
|
|
180
|
-
_getHistory: function () {
|
|
181
|
-
return window.history;
|
|
182
|
-
},
|
|
183
|
-
// This is exposed so we can mock getting window.location in our tests
|
|
184
|
-
_getLocation: function () {
|
|
185
|
-
return window.location;
|
|
186
|
-
},
|
|
187
|
-
// This is exposed so we can mock getting window.document in our tests
|
|
188
|
-
_getDocument: function () {
|
|
189
|
-
return window.document;
|
|
190
|
-
}
|
|
191
216
|
}); // IDX
|
|
192
217
|
|
|
218
|
+
const boundStartTransaction = _idx.startTransaction.bind(null, this);
|
|
219
|
+
|
|
193
220
|
this.idx = {
|
|
194
221
|
interact: _idx.interact.bind(null, this),
|
|
195
222
|
introspect: _idx.introspect.bind(null, this),
|
|
196
223
|
authenticate: _idx.authenticate.bind(null, this),
|
|
197
224
|
register: _idx.register.bind(null, this),
|
|
225
|
+
start: boundStartTransaction,
|
|
226
|
+
startTransaction: boundStartTransaction,
|
|
227
|
+
// Use `start` instead. `startTransaction` will be removed in 7.0
|
|
198
228
|
poll: _idx.poll.bind(null, this),
|
|
199
229
|
proceed: _idx.proceed.bind(null, this),
|
|
200
230
|
cancel: _idx.cancel.bind(null, this),
|
|
201
231
|
recoverPassword: _idx.recoverPassword.bind(null, this),
|
|
232
|
+
// oauth redirect callback
|
|
202
233
|
handleInteractionCodeRedirect: _idx.handleInteractionCodeRedirect.bind(null, this),
|
|
203
|
-
|
|
234
|
+
// interaction required callback
|
|
235
|
+
isInteractionRequired: _oidc.isInteractionRequired.bind(null, this),
|
|
236
|
+
isInteractionRequiredError: _oidc.isInteractionRequiredError,
|
|
237
|
+
// email verify callback
|
|
238
|
+
handleEmailVerifyCallback: _idx.handleEmailVerifyCallback.bind(null, this),
|
|
239
|
+
isEmailVerifyCallback: _idx.isEmailVerifyCallback,
|
|
240
|
+
parseEmailVerifyCallback: _idx.parseEmailVerifyCallback,
|
|
241
|
+
isEmailVerifyCallbackError: _idx.isEmailVerifyCallbackError,
|
|
242
|
+
getSavedTransactionMeta: _transactionMeta.getSavedTransactionMeta.bind(null, this),
|
|
243
|
+
createTransactionMeta: _transactionMeta.createTransactionMeta.bind(null, this),
|
|
244
|
+
getTransactionMeta: _transactionMeta.getTransactionMeta.bind(null, this),
|
|
245
|
+
saveTransactionMeta: _transactionMeta.saveTransactionMeta.bind(null, this),
|
|
246
|
+
clearTransactionMeta: _transactionMeta.clearTransactionMeta.bind(null, this),
|
|
247
|
+
isTransactionMetaValid: _transactionMeta.isTransactionMetaValid,
|
|
204
248
|
setFlow: flow => {
|
|
205
249
|
this.options.flow = flow;
|
|
206
250
|
},
|
|
207
251
|
getFlow: () => {
|
|
208
252
|
return this.options.flow;
|
|
209
253
|
},
|
|
210
|
-
canProceed: _idx.canProceed.bind(null, this)
|
|
254
|
+
canProceed: _idx.canProceed.bind(null, this),
|
|
255
|
+
unlockAccount: _idx.unlockAccount.bind(null, this)
|
|
211
256
|
};
|
|
212
257
|
(0, _headers.setGlobalRequestInterceptor)((0, _headers.createGlobalRequestInterceptor)(this)); // to pass custom headers to IDX endpoints
|
|
213
258
|
// HTTP
|
|
@@ -217,54 +262,41 @@ class OktaAuth {
|
|
|
217
262
|
}; // Fingerprint API
|
|
218
263
|
|
|
219
264
|
this.fingerprint = _fingerprint.default.bind(null, this);
|
|
220
|
-
this.emitter = new
|
|
265
|
+
this.emitter = new _tinyEmitter.default(); // TokenManager
|
|
221
266
|
|
|
222
267
|
this.tokenManager = new _TokenManager.TokenManager(this, args.tokenManager); // AuthStateManager
|
|
223
268
|
|
|
224
|
-
this.authStateManager = new _AuthStateManager.AuthStateManager(this);
|
|
269
|
+
this.authStateManager = new _AuthStateManager.AuthStateManager(this); // ServiceManager
|
|
270
|
+
|
|
271
|
+
this.serviceManager = new _ServiceManager.ServiceManager(this, args.services);
|
|
225
272
|
}
|
|
226
273
|
|
|
227
274
|
start() {
|
|
275
|
+
// TODO: review tokenManager.start
|
|
228
276
|
this.tokenManager.start();
|
|
229
277
|
|
|
230
278
|
if (!this.token.isLoginRedirect()) {
|
|
231
279
|
this.authStateManager.updateAuthState();
|
|
232
280
|
}
|
|
281
|
+
|
|
282
|
+
this.serviceManager.start();
|
|
233
283
|
}
|
|
234
284
|
|
|
235
285
|
stop() {
|
|
286
|
+
// TODO: review tokenManager.stop
|
|
236
287
|
this.tokenManager.stop();
|
|
288
|
+
this.serviceManager.stop();
|
|
237
289
|
}
|
|
238
290
|
|
|
239
291
|
setHeaders(headers) {
|
|
240
|
-
this.options.headers =
|
|
241
|
-
} //
|
|
242
|
-
// CommonJS module users (CDN) need all exports on this object
|
|
243
|
-
// Utility methods for interaction code flow
|
|
292
|
+
this.options.headers = (0, _assign.default)({}, this.options.headers, headers);
|
|
293
|
+
} // Authn V1
|
|
244
294
|
|
|
245
295
|
|
|
246
|
-
isInteractionRequired(hashOrSearch) {
|
|
247
|
-
return (0, _oidc.isInteractionRequired)(this, hashOrSearch);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
isInteractionRequiredError(error) {
|
|
251
|
-
return (0, _oidc.isInteractionRequiredError)(error);
|
|
252
|
-
} // Utility methods for email verify callback
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
isEmailVerifyCallback(urlPath) {
|
|
256
|
-
return (0, _util.isEmailVerifyCallback)(urlPath);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
parseEmailVerifyCallback(urlPath) {
|
|
260
|
-
return (0, _util.parseEmailVerifyCallback)(urlPath);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
296
|
async signIn(opts) {
|
|
264
|
-
// TODO: support interaction code flow
|
|
265
|
-
// Authn V1 flow
|
|
266
297
|
return this.signInWithCredentials(opts);
|
|
267
|
-
}
|
|
298
|
+
} // Authn V1
|
|
299
|
+
|
|
268
300
|
|
|
269
301
|
async signInWithCredentials(opts) {
|
|
270
302
|
opts = (0, _util.clone)(opts || {});
|
|
@@ -306,7 +338,7 @@ class OktaAuth {
|
|
|
306
338
|
this.setOriginalUri(originalUri);
|
|
307
339
|
}
|
|
308
340
|
|
|
309
|
-
const params =
|
|
341
|
+
const params = (0, _assign.default)({
|
|
310
342
|
// TODO: remove this line when default scopes are changed OKTA-343294
|
|
311
343
|
scopes: this.options.scopes || ['openid', 'email', 'profile']
|
|
312
344
|
}, additionalParams);
|
|
@@ -342,7 +374,7 @@ class OktaAuth {
|
|
|
342
374
|
|
|
343
375
|
|
|
344
376
|
if (!accessToken) {
|
|
345
|
-
return
|
|
377
|
+
return _promise.default.resolve(null);
|
|
346
378
|
}
|
|
347
379
|
|
|
348
380
|
return this.token.revoke(accessToken);
|
|
@@ -358,7 +390,7 @@ class OktaAuth {
|
|
|
358
390
|
|
|
359
391
|
|
|
360
392
|
if (!refreshToken) {
|
|
361
|
-
return
|
|
393
|
+
return _promise.default.resolve(null);
|
|
362
394
|
}
|
|
363
395
|
|
|
364
396
|
return this.token.revoke(refreshToken);
|
|
@@ -402,7 +434,7 @@ class OktaAuth {
|
|
|
402
434
|
|
|
403
435
|
|
|
404
436
|
async signOut(options) {
|
|
405
|
-
options =
|
|
437
|
+
options = (0, _assign.default)({}, options); // postLogoutRedirectUri must be whitelisted in Okta Admin UI
|
|
406
438
|
|
|
407
439
|
var defaultUri = window.location.origin;
|
|
408
440
|
var currentUri = window.location.href;
|
|
@@ -448,11 +480,11 @@ class OktaAuth {
|
|
|
448
480
|
}
|
|
449
481
|
});
|
|
450
482
|
} else {
|
|
451
|
-
if (options.
|
|
452
|
-
this.tokenManager.addPendingRemoveFlags();
|
|
453
|
-
} else {
|
|
483
|
+
if (options.clearTokensBeforeRedirect) {
|
|
454
484
|
// Clear all local tokens
|
|
455
485
|
this.tokenManager.clear();
|
|
486
|
+
} else {
|
|
487
|
+
this.tokenManager.addPendingRemoveFlags();
|
|
456
488
|
} // Flow ends with logout redirect
|
|
457
489
|
|
|
458
490
|
|
|
@@ -475,38 +507,44 @@ class OktaAuth {
|
|
|
475
507
|
// If `autoRenew` option is set, will attempt to renew expired tokens before returning.
|
|
476
508
|
|
|
477
509
|
|
|
478
|
-
async isAuthenticated() {
|
|
479
|
-
|
|
480
|
-
accessToken,
|
|
481
|
-
idToken
|
|
482
|
-
} = this.tokenManager.getTokensSync();
|
|
510
|
+
async isAuthenticated(options = {}) {
|
|
511
|
+
// TODO: remove dependency on tokenManager options in next major version - OKTA-473815
|
|
483
512
|
const {
|
|
484
513
|
autoRenew,
|
|
485
514
|
autoRemove
|
|
486
515
|
} = this.tokenManager.getOptions();
|
|
516
|
+
const shouldRenew = options.onExpiredToken ? options.onExpiredToken === 'renew' : autoRenew;
|
|
517
|
+
const shouldRemove = options.onExpiredToken ? options.onExpiredToken === 'remove' : autoRemove;
|
|
518
|
+
let {
|
|
519
|
+
accessToken
|
|
520
|
+
} = this.tokenManager.getTokensSync();
|
|
487
521
|
|
|
488
522
|
if (accessToken && this.tokenManager.hasExpired(accessToken)) {
|
|
489
|
-
accessToken =
|
|
523
|
+
accessToken = undefined;
|
|
490
524
|
|
|
491
|
-
if (
|
|
525
|
+
if (shouldRenew) {
|
|
492
526
|
try {
|
|
493
527
|
accessToken = await this.tokenManager.renew('accessToken');
|
|
494
528
|
} catch {// Renew errors will emit an "error" event
|
|
495
529
|
}
|
|
496
|
-
} else if (
|
|
530
|
+
} else if (shouldRemove) {
|
|
497
531
|
this.tokenManager.remove('accessToken');
|
|
498
532
|
}
|
|
499
533
|
}
|
|
500
534
|
|
|
535
|
+
let {
|
|
536
|
+
idToken
|
|
537
|
+
} = this.tokenManager.getTokensSync();
|
|
538
|
+
|
|
501
539
|
if (idToken && this.tokenManager.hasExpired(idToken)) {
|
|
502
|
-
idToken =
|
|
540
|
+
idToken = undefined;
|
|
503
541
|
|
|
504
|
-
if (
|
|
542
|
+
if (shouldRenew) {
|
|
505
543
|
try {
|
|
506
544
|
idToken = await this.tokenManager.renew('idToken');
|
|
507
545
|
} catch {// Renew errors will emit an "error" event
|
|
508
546
|
}
|
|
509
|
-
} else if (
|
|
547
|
+
} else if (shouldRemove) {
|
|
510
548
|
this.tokenManager.remove('idToken');
|
|
511
549
|
}
|
|
512
550
|
}
|
|
@@ -584,7 +622,7 @@ class OktaAuth {
|
|
|
584
622
|
|
|
585
623
|
const storage = _browserStorage.default.getSessionStorage();
|
|
586
624
|
|
|
587
|
-
return storage ? storage.getItem(constants.REFERRER_PATH_STORAGE_KEY) : undefined;
|
|
625
|
+
return storage ? storage.getItem(constants.REFERRER_PATH_STORAGE_KEY) || undefined : undefined;
|
|
588
626
|
}
|
|
589
627
|
|
|
590
628
|
removeOriginalUri(state) {
|
|
@@ -597,7 +635,7 @@ class OktaAuth {
|
|
|
597
635
|
|
|
598
636
|
if (state) {
|
|
599
637
|
const sharedStorage = this.storageManager.getOriginalUriStorage();
|
|
600
|
-
sharedStorage.removeItem(state);
|
|
638
|
+
sharedStorage.removeItem && sharedStorage.removeItem(state);
|
|
601
639
|
}
|
|
602
640
|
}
|
|
603
641
|
|
|
@@ -612,11 +650,17 @@ class OktaAuth {
|
|
|
612
650
|
this.tokenManager.setTokens(tokens);
|
|
613
651
|
originalUri = originalUri || this.getOriginalUri(this.options.state);
|
|
614
652
|
} else if (this.isLoginRedirect()) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
653
|
+
try {
|
|
654
|
+
// For redirect flow, get state from the URL and use it to retrieve the originalUri
|
|
655
|
+
const oAuthResponse = await (0, _parseFromUrl.parseOAuthResponseFromUrl)(this, {});
|
|
656
|
+
state = oAuthResponse.state;
|
|
657
|
+
originalUri = originalUri || this.getOriginalUri(state);
|
|
658
|
+
await this.storeTokensFromRedirect();
|
|
659
|
+
} catch (e) {
|
|
660
|
+
// auth state should be updated
|
|
661
|
+
await this.authStateManager.updateAuthState();
|
|
662
|
+
throw e;
|
|
663
|
+
}
|
|
620
664
|
} else {
|
|
621
665
|
return; // nothing to do
|
|
622
666
|
} // ensure auth state has been updated
|
|
@@ -632,7 +676,7 @@ class OktaAuth {
|
|
|
632
676
|
|
|
633
677
|
if (restoreOriginalUri) {
|
|
634
678
|
await restoreOriginalUri(this, originalUri);
|
|
635
|
-
} else {
|
|
679
|
+
} else if (originalUri) {
|
|
636
680
|
window.location.replace(originalUri);
|
|
637
681
|
}
|
|
638
682
|
}
|
|
@@ -645,7 +689,9 @@ class OktaAuth {
|
|
|
645
689
|
let hasResponseType = false;
|
|
646
690
|
|
|
647
691
|
if (Array.isArray(this.options.responseType) && this.options.responseType.length) {
|
|
648
|
-
|
|
692
|
+
var _context;
|
|
693
|
+
|
|
694
|
+
hasResponseType = (0, _indexOf.default)(_context = this.options.responseType).call(_context, responseType) >= 0;
|
|
649
695
|
} else {
|
|
650
696
|
hasResponseType = this.options.responseType === responseType;
|
|
651
697
|
}
|
|
@@ -663,6 +709,7 @@ class OktaAuth {
|
|
|
663
709
|
|
|
664
710
|
getIssuerOrigin() {
|
|
665
711
|
// Infer the URL from the issuer URL, omitting the /oauth2/{authServerId}
|
|
712
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
666
713
|
return this.options.issuer.split('/oauth2/')[0];
|
|
667
714
|
} // { username, (relayState) }
|
|
668
715
|
|
|
@@ -679,16 +726,29 @@ class OktaAuth {
|
|
|
679
726
|
|
|
680
727
|
verifyRecoveryToken(opts) {
|
|
681
728
|
return (0, _tx.postToTransaction)(this, '/api/v1/authn/recovery/token', opts);
|
|
729
|
+
} // Escape hatch method to make arbitrary OKTA API call
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
async invokeApiMethod(options) {
|
|
733
|
+
if (!options.accessToken) {
|
|
734
|
+
const accessToken = (await this.tokenManager.getTokens()).accessToken;
|
|
735
|
+
options.accessToken = accessToken === null || accessToken === void 0 ? void 0 : accessToken.accessToken;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
return (0, _http.httpRequest)(this, options);
|
|
682
739
|
}
|
|
683
740
|
|
|
684
741
|
} // Hoist feature detection functions to static type
|
|
685
742
|
|
|
686
743
|
|
|
687
|
-
OktaAuth.features = OktaAuth.prototype.features = features; //
|
|
744
|
+
OktaAuth.features = OktaAuth.prototype.features = features; // Hoist crypto utils to static type
|
|
745
|
+
|
|
746
|
+
OktaAuth.crypto = crypto; // Hoist webauthn utils to static type
|
|
747
|
+
|
|
748
|
+
OktaAuth.webauthn = webauthn; // Also hoist constants for CommonJS users
|
|
688
749
|
|
|
689
|
-
|
|
690
|
-
constants
|
|
691
|
-
isInteractionRequiredError: _oidc.isInteractionRequiredError
|
|
750
|
+
(0, _assign.default)(OktaAuth, {
|
|
751
|
+
constants
|
|
692
752
|
});
|
|
693
753
|
var _default = OktaAuth;
|
|
694
754
|
exports.default = _default;
|