@okta/okta-auth-js 6.0.0 → 6.3.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 +65 -0
- package/README.md +58 -27
- package/cjs/AuthStateManager.js +21 -7
- package/cjs/AuthStateManager.js.map +1 -1
- package/cjs/OktaAuth.js +96 -40
- package/cjs/OktaAuth.js.map +1 -1
- package/cjs/OktaUserAgent.js +2 -2
- package/cjs/PromiseQueue.js +14 -3
- 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 +13 -8
- package/cjs/StorageManager.js.map +1 -1
- package/cjs/TokenManager.js +34 -32
- package/cjs/TokenManager.js.map +1 -1
- package/cjs/TransactionManager.js +17 -5
- package/cjs/TransactionManager.js.map +1 -1
- package/cjs/browser/browserStorage.js +48 -33
- package/cjs/browser/browserStorage.js.map +1 -1
- package/cjs/browser/fingerprint.js +9 -3
- package/cjs/browser/fingerprint.js.map +1 -1
- package/cjs/builderUtil.js +4 -2
- 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/fetch/fetchRequest.js +18 -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 +9 -5
- package/cjs/http/request.js.map +1 -1
- package/cjs/idx/authenticate.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js +12 -3
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/OktaVerifyTotp.js +9 -1
- package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +15 -2
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js +10 -2
- package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +13 -3
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnEnrollment.js +51 -0
- package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -0
- package/cjs/idx/authenticator/WebauthnVerification.js +60 -0
- package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -0
- package/cjs/idx/authenticator/getAuthenticator.js +13 -1
- 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/authenticator/util.js +64 -0
- package/cjs/idx/authenticator/util.js.map +1 -0
- package/cjs/idx/cancel.js.map +1 -1
- package/cjs/idx/emailVerify.js +1 -1
- package/cjs/idx/emailVerify.js.map +1 -1
- package/cjs/idx/flow/AccountUnlockFlow.js +30 -0
- package/cjs/idx/flow/AccountUnlockFlow.js.map +1 -0
- package/cjs/idx/flow/FlowSpecification.js +8 -0
- 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/index.js +20 -5
- package/cjs/idx/flow/index.js.map +1 -1
- package/cjs/idx/handleInteractionCodeRedirect.js +5 -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 +40 -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 +62 -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 +111 -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 +65 -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 +120 -121
- package/cjs/idx/index.js.map +1 -1
- package/cjs/idx/interact.js +9 -4
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/introspect.js +19 -9
- 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 +14 -11
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/recoverPassword.js.map +1 -1
- package/cjs/idx/register.js +5 -1
- package/cjs/idx/register.js.map +1 -1
- package/cjs/idx/remediate.js +112 -88
- package/cjs/idx/remediate.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +16 -6
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +61 -16
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +44 -20
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +116 -82
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +58 -34
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +30 -7
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengeAuthenticator.js +2 -2
- package/cjs/idx/remediators/ChallengePoll.js +10 -3
- package/cjs/idx/remediators/ChallengePoll.js.map +1 -1
- package/cjs/idx/remediators/EnrollAuthenticator.js +2 -2
- package/cjs/idx/remediators/EnrollPoll.js +16 -6
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
- package/cjs/idx/remediators/EnrollProfile.js +34 -16
- package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/EnrollmentChannelData.js +25 -17
- package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
- package/cjs/idx/remediators/Identify.js +16 -7
- package/cjs/idx/remediators/Identify.js.map +1 -1
- package/cjs/idx/remediators/ReEnrollAuthenticator.js +13 -10
- 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/SelectAuthenticatorAuthenticate.js +9 -6
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorEnroll.js +2 -2
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +71 -0
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -0
- package/cjs/idx/remediators/SelectEnrollProfile.js +2 -2
- package/cjs/idx/remediators/SelectEnrollmentChannel.js +22 -10
- package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
- package/cjs/idx/remediators/Skip.js +5 -10
- package/cjs/idx/remediators/Skip.js.map +1 -1
- package/cjs/idx/remediators/index.js +33 -18
- package/cjs/idx/remediators/index.js.map +1 -1
- package/cjs/idx/remediators/util.js +13 -3
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +276 -177
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/startTransaction.js.map +1 -1
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/types/index.js +82 -9
- 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/idx/util.js +198 -0
- package/cjs/idx/util.js.map +1 -0
- package/cjs/index.js +20 -14
- package/cjs/index.js.map +1 -1
- package/cjs/oidc/endpoints/authorize.js +8 -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 +15 -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 +10 -2
- package/cjs/oidc/exchangeCodeForTokens.js.map +1 -1
- package/cjs/oidc/getToken.js +9 -5
- 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 +5 -1
- 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 +9 -3
- 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 +5 -1
- 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 +7 -3
- 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 +14 -12
- package/cjs/oidc/util/index.js.map +1 -1
- package/cjs/oidc/util/loginRedirect.js +5 -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.map +1 -1
- package/cjs/oidc/util/pkce.js +11 -3
- package/cjs/oidc/util/pkce.js.map +1 -1
- package/cjs/oidc/util/prepareTokenParams.js +7 -5
- package/cjs/oidc/util/prepareTokenParams.js.map +1 -1
- package/cjs/oidc/util/validateClaims.js +1 -1
- package/cjs/oidc/util/validateClaims.js.map +1 -1
- package/cjs/oidc/verifyToken.js +11 -3
- package/cjs/oidc/verifyToken.js.map +1 -1
- package/cjs/options/browser.js +86 -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 +45 -0
- package/cjs/options/node.js.map +1 -0
- package/cjs/options.js +17 -5
- package/cjs/options.js.map +1 -1
- package/cjs/server/serverStorage.js +8 -4
- 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 +15 -9
- package/cjs/tx/AuthTransaction.js.map +1 -1
- package/cjs/tx/api.js +8 -4
- 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 -5
- 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/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} +2978 -2585
- package/esm/esm.browser.js.map +1 -0
- package/esm/esm.node.mjs +9595 -0
- package/esm/esm.node.mjs.map +1 -0
- package/lib/AuthStateManager.d.ts +3 -3
- package/lib/OktaAuth.d.ts +10 -6
- package/lib/PromiseQueue.d.ts +6 -2
- package/lib/ServiceManager.d.ts +38 -0
- package/lib/StorageManager.d.ts +1 -1
- package/lib/TokenManager.d.ts +2 -3
- package/lib/TransactionManager.d.ts +4 -5
- package/lib/browser/fingerprint.d.ts +2 -3
- package/lib/crypto/base64.d.ts +2 -0
- package/lib/crypto/webauthn.d.ts +25 -0
- 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 +8 -9
- package/lib/idx/authenticator/OktaVerifyTotp.d.ts +1 -1
- package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +11 -12
- package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +7 -7
- package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +8 -3
- 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/authenticator/util.d.ts +4 -0
- package/lib/idx/cancel.d.ts +2 -2
- package/lib/idx/emailVerify.d.ts +2 -2
- package/lib/idx/flow/AccountUnlockFlow.d.ts +13 -0
- package/lib/idx/flow/FlowSpecification.d.ts +2 -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 +35 -0
- package/lib/idx/idx-js/interact.d.ts +25 -0
- package/lib/idx/idx-js/introspect.d.ts +21 -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 -11
- package/lib/idx/interact.d.ts +3 -2
- package/lib/idx/introspect.d.ts +2 -2
- package/lib/idx/poll.d.ts +2 -2
- package/lib/idx/proceed.d.ts +5 -6
- package/lib/idx/recoverPassword.d.ts +2 -2
- package/lib/idx/register.d.ts +2 -2
- package/lib/idx/remediate.d.ts +2 -2
- package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +6 -5
- package/lib/idx/remediators/Base/AuthenticatorData.d.ts +5 -8
- package/lib/idx/remediators/Base/Remediator.d.ts +6 -5
- package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +9 -8
- package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +9 -16
- package/lib/idx/remediators/ChallengePoll.d.ts +1 -0
- package/lib/idx/remediators/EnrollProfile.d.ts +0 -3
- package/lib/idx/remediators/EnrollmentChannelData.d.ts +1 -4
- package/lib/idx/remediators/Identify.d.ts +3 -5
- package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -5
- package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +2 -1
- package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +37 -0
- package/lib/idx/remediators/SelectEnrollmentChannel.d.ts +1 -0
- package/lib/idx/remediators/Skip.d.ts +0 -3
- package/lib/idx/remediators/index.d.ts +1 -0
- package/lib/idx/run.d.ts +2 -2
- package/lib/idx/startTransaction.d.ts +2 -2
- package/lib/idx/transactionMeta.d.ts +7 -7
- package/lib/idx/types/FlowIdentifier.d.ts +1 -1
- package/lib/idx/types/idx-js.d.ts +41 -1
- package/lib/idx/types/index.d.ts +27 -7
- package/lib/idx/unlockAccount.d.ts +15 -0
- package/lib/idx/util.d.ts +11 -0
- package/lib/oidc/endpoints/well-known.d.ts +3 -3
- package/lib/oidc/exchangeCodeForTokens.d.ts +2 -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/renewToken.d.ts +2 -2
- package/lib/oidc/renewTokensWithRefresh.d.ts +2 -2
- package/lib/oidc/revokeToken.d.ts +2 -2
- package/lib/oidc/util/browser.d.ts +2 -2
- package/lib/oidc/util/defaultTokenParams.d.ts +2 -2
- package/lib/oidc/util/errors.d.ts +2 -2
- package/lib/oidc/util/loginRedirect.d.ts +4 -4
- package/lib/oidc/util/oauth.d.ts +4 -4
- package/lib/oidc/util/oauthMeta.d.ts +2 -2
- package/lib/oidc/util/prepareTokenParams.d.ts +5 -5
- 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/index.d.ts +14 -0
- package/lib/options/node.d.ts +16 -0
- 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/types/OktaAuthOptions.d.ts +6 -2
- package/lib/types/Service.d.ts +23 -0
- package/lib/types/Storage.d.ts +7 -5
- package/lib/types/Transaction.d.ts +2 -10
- package/lib/types/api.d.ts +23 -10
- package/lib/types/index.d.ts +1 -1
- package/lib/util/sharedStorage.d.ts +1 -1
- package/package.json +32 -14
- package/polyfill/index.js +1 -0
- package/cjs/services/TokenService.js +0 -111
- package/cjs/services/TokenService.js.map +0 -1
- package/esm/index.js.map +0 -1
package/lib/types/api.d.ts
CHANGED
|
@@ -14,17 +14,17 @@ import { Token, Tokens, RevocableToken, AccessToken, IDToken, RefreshToken } fro
|
|
|
14
14
|
import { JWTObject } from './JWT';
|
|
15
15
|
import { UserClaims } from './UserClaims';
|
|
16
16
|
import { CustomUrls, OktaAuthOptions } from './OktaAuthOptions';
|
|
17
|
-
import StorageManager from '../StorageManager';
|
|
17
|
+
import { StorageManager } from '../StorageManager';
|
|
18
18
|
import TransactionManager from '../TransactionManager';
|
|
19
19
|
import { TokenManagerInterface } from './TokenManager';
|
|
20
|
+
import { ServiceManagerInterface } from './Service';
|
|
20
21
|
import { OktaUserAgent } from '../OktaUserAgent';
|
|
21
|
-
import { FlowIdentifier, IdxPollOptions } from '../idx/types';
|
|
22
|
-
import { AuthenticationOptions, RegistrationOptions as IdxRegistrationOptions, PasswordRecoveryOptions, ProceedOptions, CancelOptions, IdxOptions, IdxTransaction, IdxTransactionMeta, EmailVerifyCallbackResponse } from '../idx/types';
|
|
22
|
+
import { AuthenticationOptions, RegistrationOptions as IdxRegistrationOptions, PasswordRecoveryOptions, AccountUnlockOptions, ProceedOptions, CancelOptions, IdxOptions, IdxTransaction, IdxTransactionMeta, EmailVerifyCallbackResponse, IdxAuthenticator, ChallengeData, ActivationData, WebauthnEnrollValues, WebauthnVerificationValues, FlowIdentifier, IdxPollOptions } from '../idx/types';
|
|
23
23
|
import { InteractOptions, InteractResponse } from '../idx/interact';
|
|
24
24
|
import { IntrospectOptions } from '../idx/introspect';
|
|
25
25
|
import { IdxResponse } from '../idx/types/idx-js';
|
|
26
26
|
import { TransactionMetaOptions } from './Transaction';
|
|
27
|
-
export interface
|
|
27
|
+
export interface OktaAuthInterface {
|
|
28
28
|
options: OktaAuthOptions;
|
|
29
29
|
getIssuerOrigin(): string;
|
|
30
30
|
getOriginalUri(): string | undefined;
|
|
@@ -32,6 +32,7 @@ export interface OktaAuth {
|
|
|
32
32
|
storageManager: StorageManager;
|
|
33
33
|
transactionManager: TransactionManager;
|
|
34
34
|
tokenManager: TokenManagerInterface;
|
|
35
|
+
serviceManager: ServiceManagerInterface;
|
|
35
36
|
idx: IdxAPI;
|
|
36
37
|
features: FeaturesAPI;
|
|
37
38
|
token: TokenAPI;
|
|
@@ -162,20 +163,33 @@ export interface FeaturesAPI {
|
|
|
162
163
|
isPKCESupported(): boolean;
|
|
163
164
|
isIE11OrLess(): boolean;
|
|
164
165
|
}
|
|
166
|
+
export interface CryptoAPI {
|
|
167
|
+
base64UrlToBuffer(b64u: string): Uint8Array;
|
|
168
|
+
bufferToBase64Url(bin: Uint8Array): string;
|
|
169
|
+
}
|
|
170
|
+
export interface WebauthnAPI {
|
|
171
|
+
getAssertion(credential: PublicKeyCredential): WebauthnVerificationValues;
|
|
172
|
+
getAttestation(credential: PublicKeyCredential): WebauthnEnrollValues;
|
|
173
|
+
buildCredentialRequestOptions(challengeData: ChallengeData, authenticatorEnrollments: IdxAuthenticator[]): CredentialRequestOptions;
|
|
174
|
+
buildCredentialCreationOptions(activationData: ActivationData, authenticatorEnrollments: IdxAuthenticator[]): CredentialCreationOptions;
|
|
175
|
+
}
|
|
165
176
|
export interface SupportsCodeFlow {
|
|
166
177
|
useInteractionCodeFlow?: boolean;
|
|
167
178
|
}
|
|
168
179
|
export interface SigninOptions extends SupportsCodeFlow, AuthenticationOptions {
|
|
169
180
|
relayState?: string;
|
|
170
|
-
context?:
|
|
181
|
+
context?: {
|
|
182
|
+
deviceToken?: string;
|
|
183
|
+
};
|
|
171
184
|
sendFingerprint?: boolean;
|
|
185
|
+
stateToken?: string;
|
|
172
186
|
}
|
|
173
187
|
export interface SigninWithRedirectOptions extends SigninOptions, TokenParams {
|
|
174
188
|
originalUri?: string;
|
|
175
189
|
}
|
|
176
190
|
export interface SigninWithCredentialsOptions extends SigninOptions {
|
|
177
|
-
username
|
|
178
|
-
password
|
|
191
|
+
username?: string;
|
|
192
|
+
password?: string;
|
|
179
193
|
}
|
|
180
194
|
export interface SigninAPI {
|
|
181
195
|
signIn(opts: SigninOptions): Promise<AuthTransaction>;
|
|
@@ -215,11 +229,10 @@ export interface IdxAPI {
|
|
|
215
229
|
authenticate: (options?: AuthenticationOptions) => Promise<IdxTransaction>;
|
|
216
230
|
register: (options?: IdxRegistrationOptions) => Promise<IdxTransaction>;
|
|
217
231
|
recoverPassword: (options?: PasswordRecoveryOptions) => Promise<IdxTransaction>;
|
|
232
|
+
unlockAccount: (options?: AccountUnlockOptions) => Promise<IdxTransaction>;
|
|
218
233
|
poll: (options?: IdxPollOptions) => Promise<IdxTransaction>;
|
|
219
234
|
start: (options?: IdxOptions) => Promise<IdxTransaction>;
|
|
220
|
-
canProceed(options?:
|
|
221
|
-
state?: string;
|
|
222
|
-
}): boolean;
|
|
235
|
+
canProceed(options?: ProceedOptions): boolean;
|
|
223
236
|
proceed: (options?: ProceedOptions) => Promise<IdxTransaction>;
|
|
224
237
|
cancel: (options?: CancelOptions) => Promise<IdxTransaction>;
|
|
225
238
|
getFlow(): FlowIdentifier | undefined;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransactionMeta } from '../types';
|
|
2
|
-
import StorageManager from '../StorageManager';
|
|
2
|
+
import { StorageManager } from '../StorageManager';
|
|
3
3
|
export declare function pruneSharedStorage(storageManager: StorageManager): void;
|
|
4
4
|
export declare function saveTransactionToSharedStorage(storageManager: StorageManager, state: string, meta: TransactionMeta): void;
|
|
5
5
|
export declare function loadTransactionFromSharedStorage(storageManager: StorageManager, state: string): any;
|
package/package.json
CHANGED
|
@@ -2,13 +2,23 @@
|
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@okta/okta-auth-js",
|
|
4
4
|
"description": "The Okta Auth SDK",
|
|
5
|
-
"version": "6.
|
|
5
|
+
"version": "6.3.0",
|
|
6
6
|
"homepage": "https://github.com/okta/okta-auth-js",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "cjs/index.js",
|
|
9
|
-
"module": "esm/
|
|
9
|
+
"module": "esm/esm.node.mjs",
|
|
10
10
|
"browser": "dist/okta-auth-js.umd.js",
|
|
11
11
|
"types": "lib/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
"node": {
|
|
14
|
+
"import": "./esm/esm.node.mjs",
|
|
15
|
+
"require": "./cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"import": "./esm/esm.browser.js"
|
|
19
|
+
},
|
|
20
|
+
"default": "./dist/okta-auth-js.umd.js"
|
|
21
|
+
},
|
|
12
22
|
"repository": {
|
|
13
23
|
"type": "git",
|
|
14
24
|
"url": "https://github.com/okta/okta-auth-js.git"
|
|
@@ -20,8 +30,9 @@
|
|
|
20
30
|
"banners": "node ./scripts/maintain-banners.js",
|
|
21
31
|
"clean": "yarn clean:build",
|
|
22
32
|
"clean:build": "rimraf build && rimraf build2",
|
|
23
|
-
"dev": "
|
|
24
|
-
"
|
|
33
|
+
"dev:esm": "NODE_ENV=development yarn build:esm --watch",
|
|
34
|
+
"dev:web": "cross-env NODE_ENV=development webpack --config webpack.config.js --watch",
|
|
35
|
+
"lint": "eslint --ext .js,.ts,.jsx .",
|
|
25
36
|
"tsd": "tsd",
|
|
26
37
|
"lint:report": "eslint -f checkstyle -o ./build2/reports/lint/eslint-checkstyle-result.xml .",
|
|
27
38
|
"validate": "yarn tsc --noEmit && yarn lint && yarn workspace @okta/test.app validate && yarn tsd",
|
|
@@ -36,6 +47,9 @@
|
|
|
36
47
|
"test:report": "yarn test --ci --silent || true",
|
|
37
48
|
"test:samples": "yarn workspace @okta/test.e2e.samples start",
|
|
38
49
|
"test:integration": "jest --config ./jest.integration.js",
|
|
50
|
+
"test:bundle:esm:browser": "cross-env BUNDLE_ENV=browser NODE_OPTIONS=--experimental-vm-modules jest --config ./jest.esm.mjs",
|
|
51
|
+
"test:bundle:esm:node": "cross-env BUNDLE_ENV=node NODE_OPTIONS=--experimental-vm-modules jest --config ./jest.esm.mjs",
|
|
52
|
+
"test:bundle:cjs": "cross-env BUNDLE_ENV=node jest --config ./jest.cjs.js",
|
|
39
53
|
"build": "node scripts/build.js",
|
|
40
54
|
"build:cdn": "cross-env NODE_ENV=production webpack --config webpack.cdn.config.js",
|
|
41
55
|
"build:web": "cross-env NODE_ENV=production webpack --config webpack.config.js",
|
|
@@ -70,14 +84,16 @@
|
|
|
70
84
|
},
|
|
71
85
|
"dependencies": {
|
|
72
86
|
"@babel/runtime": "^7.12.5",
|
|
73
|
-
"@
|
|
87
|
+
"@babel/runtime-corejs3": "^7.17.0",
|
|
74
88
|
"@peculiar/webcrypto": "1.1.6",
|
|
75
89
|
"Base64": "1.1.0",
|
|
76
90
|
"atob": "^2.1.2",
|
|
91
|
+
"broadcast-channel": "^4.10.0",
|
|
77
92
|
"btoa": "^1.2.1",
|
|
78
93
|
"core-js": "^3.6.5",
|
|
79
|
-
"cross-fetch": "^3.
|
|
80
|
-
"js-cookie": "
|
|
94
|
+
"cross-fetch": "^3.1.5",
|
|
95
|
+
"js-cookie": "^3.0.1",
|
|
96
|
+
"jsonpath-plus": "^6.0.1",
|
|
81
97
|
"node-cache": "^5.1.2",
|
|
82
98
|
"p-cancelable": "^2.0.0",
|
|
83
99
|
"text-encoding": "^0.7.0",
|
|
@@ -94,11 +110,11 @@
|
|
|
94
110
|
"@babel/plugin-transform-typescript": "^7.10.5",
|
|
95
111
|
"@babel/preset-env": "^7.8.2",
|
|
96
112
|
"@babel/preset-typescript": "^7.10.4",
|
|
97
|
-
"@okta/okta-signin-widget": "
|
|
113
|
+
"@okta/okta-signin-widget": "6.0.0",
|
|
98
114
|
"@rollup/plugin-alias": "^3.1.8",
|
|
99
115
|
"@rollup/plugin-babel": "^5.3.0",
|
|
100
116
|
"@rollup/plugin-replace": "^3.0.0",
|
|
101
|
-
"@types/jest": "^
|
|
117
|
+
"@types/jest": "^27.4.0",
|
|
102
118
|
"@types/node": "^14.0.3",
|
|
103
119
|
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
|
104
120
|
"@typescript-eslint/parser": "^2.34.0",
|
|
@@ -109,14 +125,16 @@
|
|
|
109
125
|
"chalk": "2.4.2",
|
|
110
126
|
"cross-env": "^5.1.1",
|
|
111
127
|
"eslint": "^7.1.0",
|
|
128
|
+
"eslint-import-resolver-typescript": "^2.5.0",
|
|
112
129
|
"eslint-plugin-compat": "^3.3.0",
|
|
130
|
+
"eslint-plugin-import": "^2.25.4",
|
|
113
131
|
"eslint-plugin-jasmine": "^2.10.1",
|
|
114
132
|
"eslint-plugin-jsdoc": "^25.4.2",
|
|
115
133
|
"eslint-plugin-node": "^11.1.0",
|
|
116
134
|
"globby": "^6.1.0",
|
|
117
135
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
118
136
|
"jasmine-ajax": "^4.0.0",
|
|
119
|
-
"jest": "^
|
|
137
|
+
"jest": "^27.5.1",
|
|
120
138
|
"jest-junit": "^9.0.0",
|
|
121
139
|
"json-loader": "0.5.4",
|
|
122
140
|
"lodash": "4.17.20",
|
|
@@ -125,7 +143,7 @@
|
|
|
125
143
|
"rollup-plugin-license": "^2.6.0",
|
|
126
144
|
"rollup-plugin-typescript2": "^0.30.0",
|
|
127
145
|
"shelljs": "0.8.4",
|
|
128
|
-
"ts-jest": "^
|
|
146
|
+
"ts-jest": "^27.1.3",
|
|
129
147
|
"ts-loader": "^9.2.6",
|
|
130
148
|
"tsd": "^0.17.0",
|
|
131
149
|
"typescript": "^4.2.3",
|
|
@@ -169,8 +187,8 @@
|
|
|
169
187
|
}
|
|
170
188
|
},
|
|
171
189
|
"okta": {
|
|
172
|
-
"commitSha": "
|
|
173
|
-
"fullVersion": "6.
|
|
174
|
-
"testedSha": "
|
|
190
|
+
"commitSha": "71c3352c337ea6bdcd28b4d6b8b5070264bbcb5f",
|
|
191
|
+
"fullVersion": "6.3.0-g71c3352",
|
|
192
|
+
"testedSha": "f41646732612b51f89e13d2538ee1a0bd07b665d"
|
|
175
193
|
}
|
|
176
194
|
}
|
package/polyfill/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// Polyfills objects needed to support IE 11+
|
|
15
15
|
require('core-js/features/object/assign');
|
|
16
16
|
require('core-js/features/object/values');
|
|
17
|
+
require('core-js/features/object/from-entries');
|
|
17
18
|
require('core-js/es/promise');
|
|
18
19
|
require('core-js/es/typed-array/uint8-array');
|
|
19
20
|
require('core-js/features/array/from');
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.TokenService = void 0;
|
|
4
|
-
|
|
5
|
-
var _TokenManager = require("../TokenManager");
|
|
6
|
-
|
|
7
|
-
var _errors = require("../errors");
|
|
8
|
-
|
|
9
|
-
var _features = require("../features");
|
|
10
|
-
|
|
11
|
-
/*!
|
|
12
|
-
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
13
|
-
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
14
|
-
*
|
|
15
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
18
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
*
|
|
20
|
-
* See the License for the specific language governing permissions and limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/* global window */
|
|
24
|
-
function shouldThrottleRenew(renewTimeQueue) {
|
|
25
|
-
let res = false;
|
|
26
|
-
renewTimeQueue.push(Date.now());
|
|
27
|
-
|
|
28
|
-
if (renewTimeQueue.length >= 10) {
|
|
29
|
-
// get and remove first item from queue
|
|
30
|
-
const firstTime = renewTimeQueue.shift();
|
|
31
|
-
const lastTime = renewTimeQueue[renewTimeQueue.length - 1];
|
|
32
|
-
res = lastTime - firstTime < 30 * 1000;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return res;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class TokenService {
|
|
39
|
-
constructor(tokenManager, options = {}) {
|
|
40
|
-
this.tokenManager = tokenManager;
|
|
41
|
-
this.options = options;
|
|
42
|
-
this.storageListener = undefined;
|
|
43
|
-
this.onTokenExpiredHandler = undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
start() {
|
|
47
|
-
const renewTimeQueue = [];
|
|
48
|
-
|
|
49
|
-
this.onTokenExpiredHandler = key => {
|
|
50
|
-
if (this.options.autoRenew) {
|
|
51
|
-
if (shouldThrottleRenew(renewTimeQueue)) {
|
|
52
|
-
const error = new _errors.AuthSdkError('Too many token renew requests');
|
|
53
|
-
this.tokenManager.emitError(error);
|
|
54
|
-
} else {
|
|
55
|
-
this.tokenManager.renew(key).catch(() => {}); // Renew errors will emit an "error" event
|
|
56
|
-
}
|
|
57
|
-
} else if (this.options.autoRemove) {
|
|
58
|
-
this.tokenManager.remove(key);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this.tokenManager.on(_TokenManager.EVENT_EXPIRED, this.onTokenExpiredHandler);
|
|
63
|
-
this.tokenManager.setExpireEventTimeoutAll();
|
|
64
|
-
|
|
65
|
-
if (this.options.syncStorage && (0, _features.isBrowser)()) {
|
|
66
|
-
// Sync authState cross multiple tabs when localStorage is used as the storageProvider
|
|
67
|
-
// A StorageEvent is sent to a window when a storage area it has access to is changed
|
|
68
|
-
// within the context of another document.
|
|
69
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent
|
|
70
|
-
this.storageListener = ({
|
|
71
|
-
key,
|
|
72
|
-
newValue,
|
|
73
|
-
oldValue
|
|
74
|
-
}) => {
|
|
75
|
-
const handleCrossTabsStorageChange = () => {
|
|
76
|
-
this.tokenManager.resetExpireEventTimeoutAll();
|
|
77
|
-
this.tokenManager.emitEventsForCrossTabsStorageUpdate(newValue, oldValue);
|
|
78
|
-
}; // Skip if:
|
|
79
|
-
// not from localStorage.clear (event.key is null)
|
|
80
|
-
// event.key is not the storageKey
|
|
81
|
-
// oldValue === newValue
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (key && (key !== this.options.storageKey || newValue === oldValue)) {
|
|
85
|
-
return;
|
|
86
|
-
} // LocalStorage cross tabs update is not synced in IE, set a 1s timer by default to read latest value
|
|
87
|
-
// https://stackoverflow.com/questions/24077117/localstorage-in-win8-1-ie11-does-not-synchronize
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.syncTimeout = setTimeout(() => handleCrossTabsStorageChange(), this.options._storageEventDelay);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
window.addEventListener('storage', this.storageListener);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
stop() {
|
|
98
|
-
this.tokenManager.clearExpireEventTimeoutAll();
|
|
99
|
-
this.tokenManager.off(_TokenManager.EVENT_EXPIRED, this.onTokenExpiredHandler);
|
|
100
|
-
|
|
101
|
-
if (this.options.syncStorage && (0, _features.isBrowser)()) {
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
|
-
window.removeEventListener('storage', this.storageListener);
|
|
104
|
-
clearTimeout(this.syncTimeout);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
exports.TokenService = TokenService;
|
|
111
|
-
//# sourceMappingURL=TokenService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/services/TokenService.ts"],"names":["shouldThrottleRenew","renewTimeQueue","res","push","Date","now","length","firstTime","shift","lastTime","TokenService","constructor","tokenManager","options","storageListener","undefined","onTokenExpiredHandler","start","key","autoRenew","error","AuthSdkError","emitError","renew","catch","autoRemove","remove","on","EVENT_EXPIRED","setExpireEventTimeoutAll","syncStorage","newValue","oldValue","handleCrossTabsStorageChange","resetExpireEventTimeoutAll","emitEventsForCrossTabsStorageUpdate","storageKey","syncTimeout","setTimeout","_storageEventDelay","window","addEventListener","stop","clearExpireEventTimeoutAll","off","removeEventListener","clearTimeout"],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* global window */\nimport { TokenManager, EVENT_EXPIRED } from '../TokenManager';\nimport { AuthSdkError } from '../errors';\nimport { isBrowser } from '../features';\nimport { TokenManagerOptions } from '../types';\n\nfunction shouldThrottleRenew(renewTimeQueue) {\n let res = false;\n renewTimeQueue.push(Date.now());\n if (renewTimeQueue.length >= 10) {\n // get and remove first item from queue\n const firstTime = renewTimeQueue.shift();\n const lastTime = renewTimeQueue[renewTimeQueue.length - 1];\n res = lastTime - firstTime < 30 * 1000;\n }\n return res;\n}\n\nexport class TokenService {\n private tokenManager: TokenManager;\n private options: TokenManagerOptions;\n private storageListener?: (event: StorageEvent) => void;\n private onTokenExpiredHandler?: (key: string) => void;\n private syncTimeout: unknown;\n\n constructor(tokenManager: TokenManager, options: TokenManagerOptions = {}) {\n this.tokenManager = tokenManager;\n this.options = options;\n this.storageListener = undefined;\n this.onTokenExpiredHandler = undefined;\n }\n\n start() {\n const renewTimeQueue = [];\n this.onTokenExpiredHandler = (key) => {\n if (this.options.autoRenew) {\n if (shouldThrottleRenew(renewTimeQueue)) {\n const error = new AuthSdkError('Too many token renew requests');\n this.tokenManager.emitError(error);\n } else {\n this.tokenManager.renew(key).catch(() => {}); // Renew errors will emit an \"error\" event \n }\n } else if (this.options.autoRemove) {\n this.tokenManager.remove(key);\n }\n };\n this.tokenManager.on(EVENT_EXPIRED, this.onTokenExpiredHandler);\n\n this.tokenManager.setExpireEventTimeoutAll();\n\n if (this.options.syncStorage && isBrowser()) {\n // Sync authState cross multiple tabs when localStorage is used as the storageProvider\n // A StorageEvent is sent to a window when a storage area it has access to is changed \n // within the context of another document.\n // https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent\n\n this.storageListener = ({ key, newValue, oldValue }: StorageEvent) => {\n const handleCrossTabsStorageChange = () => {\n this.tokenManager.resetExpireEventTimeoutAll();\n this.tokenManager.emitEventsForCrossTabsStorageUpdate(newValue, oldValue);\n };\n\n // Skip if:\n // not from localStorage.clear (event.key is null)\n // event.key is not the storageKey\n // oldValue === newValue\n if (key && (key !== this.options.storageKey || newValue === oldValue)) {\n return;\n }\n\n // LocalStorage cross tabs update is not synced in IE, set a 1s timer by default to read latest value\n // https://stackoverflow.com/questions/24077117/localstorage-in-win8-1-ie11-does-not-synchronize\n this.syncTimeout = setTimeout(() => handleCrossTabsStorageChange(), this.options._storageEventDelay);\n };\n\n window.addEventListener('storage', this.storageListener);\n }\n }\n\n stop() {\n this.tokenManager.clearExpireEventTimeoutAll();\n this.tokenManager.off(EVENT_EXPIRED, this.onTokenExpiredHandler);\n if (this.options.syncStorage && isBrowser()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n window.removeEventListener('storage', this.storageListener!);\n clearTimeout(this.syncTimeout as any);\n }\n }\n}"],"file":"TokenService.js"}
|