@civic/auth 0.1.3 → 0.1.4-beta.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 +4 -0
- package/README.md +2 -2
- package/dist/cjs/browser/storage.d.ts +3 -0
- package/dist/cjs/browser/storage.d.ts.map +1 -1
- package/dist/cjs/browser/storage.js +8 -0
- package/dist/cjs/browser/storage.js.map +1 -1
- package/dist/cjs/lib/cookies.d.ts +2 -2
- package/dist/cjs/lib/cookies.d.ts.map +1 -1
- package/dist/cjs/lib/cookies.js +7 -5
- package/dist/cjs/lib/cookies.js.map +1 -1
- package/dist/cjs/lib/postMessage.js +1 -1
- package/dist/cjs/lib/postMessage.js.map +1 -1
- package/dist/cjs/lib/windowUtil.d.ts.map +1 -1
- package/dist/cjs/lib/windowUtil.js +1 -0
- package/dist/cjs/lib/windowUtil.js.map +1 -1
- package/dist/cjs/nextjs/config.d.ts.map +1 -1
- package/dist/cjs/nextjs/config.js +12 -0
- package/dist/cjs/nextjs/config.js.map +1 -1
- package/dist/cjs/nextjs/hooks/index.d.ts +1 -1
- package/dist/cjs/nextjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/nextjs/hooks/index.js +3 -3
- package/dist/cjs/nextjs/hooks/index.js.map +1 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.js +43 -14
- package/dist/cjs/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.d.ts +5 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.js +74 -35
- package/dist/cjs/nextjs/providers/NextAuthProvider.js.map +1 -1
- package/dist/cjs/reactjs/components/UserButton.js +20 -10
- package/dist/cjs/reactjs/components/UserButton.js.map +1 -1
- package/dist/cjs/reactjs/hooks/index.d.ts +0 -1
- package/dist/cjs/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/reactjs/hooks/index.js +1 -3
- package/dist/cjs/reactjs/hooks/index.js.map +1 -1
- package/dist/cjs/services/AuthenticationService.d.ts +4 -1
- package/dist/cjs/services/AuthenticationService.d.ts.map +1 -1
- package/dist/cjs/services/AuthenticationService.js +38 -7
- package/dist/cjs/services/AuthenticationService.js.map +1 -1
- package/dist/cjs/shared/components/BlockDisplay.d.ts +7 -0
- package/dist/cjs/shared/components/BlockDisplay.d.ts.map +1 -0
- package/dist/cjs/shared/components/BlockDisplay.js +31 -0
- package/dist/cjs/shared/components/BlockDisplay.js.map +1 -0
- package/dist/cjs/shared/components/CivicAuthIframe.js +17 -7
- package/dist/cjs/shared/components/CivicAuthIframe.js.map +1 -1
- package/dist/cjs/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/cjs/shared/components/CivicAuthIframeContainer.js +39 -20
- package/dist/cjs/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/cjs/shared/components/IFrameAndLoading.d.ts +7 -0
- package/dist/cjs/shared/components/IFrameAndLoading.d.ts.map +1 -0
- package/dist/cjs/shared/components/IFrameAndLoading.js +28 -0
- package/dist/cjs/shared/components/IFrameAndLoading.js.map +1 -0
- package/dist/cjs/shared/hooks/index.d.ts +5 -1
- package/dist/cjs/shared/hooks/index.d.ts.map +1 -1
- package/dist/cjs/shared/hooks/index.js +11 -3
- package/dist/cjs/shared/hooks/index.js.map +1 -1
- package/dist/cjs/shared/hooks/useCivicAuthConfig.d.ts +3 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.js +13 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.js.map +1 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.d.ts +3 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.js +16 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.js.map +1 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.d.ts +3 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.js +27 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.js.map +1 -0
- package/dist/cjs/shared/hooks/useIsInIframe.d.ts +3 -0
- package/dist/cjs/shared/hooks/useIsInIframe.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useIsInIframe.js +17 -0
- package/dist/cjs/shared/hooks/useIsInIframe.js.map +1 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.d.ts +4 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.js +17 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.js.map +1 -0
- package/dist/cjs/shared/hooks/useRefresh.d.ts +4 -0
- package/dist/cjs/shared/hooks/useRefresh.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useRefresh.js +41 -0
- package/dist/cjs/shared/hooks/useRefresh.js.map +1 -0
- package/dist/cjs/shared/hooks/useSession.d.ts +1 -1
- package/dist/cjs/shared/hooks/useSession.d.ts.map +1 -1
- package/dist/cjs/shared/hooks/useSignIn.d.ts +14 -0
- package/dist/cjs/shared/hooks/useSignIn.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useSignIn.js +74 -0
- package/dist/cjs/shared/hooks/useSignIn.js.map +1 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.d.ts +4 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.js +30 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/cjs/shared/lib/types.d.ts +14 -1
- package/dist/cjs/shared/lib/types.d.ts.map +1 -1
- package/dist/cjs/shared/lib/types.js +2 -0
- package/dist/cjs/shared/lib/types.js.map +1 -1
- package/dist/cjs/shared/lib/util.d.ts.map +1 -1
- package/dist/cjs/shared/lib/util.js +27 -9
- package/dist/cjs/shared/lib/util.js.map +1 -1
- package/dist/cjs/shared/providers/AuthProvider.d.ts +3 -2
- package/dist/cjs/shared/providers/AuthProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/AuthProvider.js +53 -244
- package/dist/cjs/shared/providers/AuthProvider.js.map +1 -1
- package/dist/cjs/shared/providers/CivicAuthConfigContext.d.ts +16 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.d.ts.map +1 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.js +80 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.js.map +1 -0
- package/dist/cjs/shared/providers/CivicAuthProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/CivicAuthProvider.js +23 -6
- package/dist/cjs/shared/providers/CivicAuthProvider.js.map +1 -1
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.d.ts +17 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.d.ts.map +1 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.js +183 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.js.map +1 -0
- package/dist/cjs/shared/providers/IframeProvider.d.ts +7 -4
- package/dist/cjs/shared/providers/IframeProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/IframeProvider.js +37 -9
- package/dist/cjs/shared/providers/IframeProvider.js.map +1 -1
- package/dist/cjs/shared/providers/SessionProvider.d.ts +10 -4
- package/dist/cjs/shared/providers/SessionProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/SessionProvider.js +32 -12
- package/dist/cjs/shared/providers/SessionProvider.js.map +1 -1
- package/dist/cjs/shared/providers/TokenProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/TokenProvider.js +29 -30
- package/dist/cjs/shared/providers/TokenProvider.js.map +1 -1
- package/dist/cjs/shared/providers/UserProvider.d.ts +4 -3
- package/dist/cjs/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/UserProvider.js +46 -25
- package/dist/cjs/shared/providers/UserProvider.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/esm/browser/storage.d.ts +3 -0
- package/dist/esm/browser/storage.d.ts.map +1 -1
- package/dist/esm/browser/storage.js +8 -0
- package/dist/esm/browser/storage.js.map +1 -1
- package/dist/esm/lib/cookies.d.ts +2 -2
- package/dist/esm/lib/cookies.d.ts.map +1 -1
- package/dist/esm/lib/cookies.js +7 -5
- package/dist/esm/lib/cookies.js.map +1 -1
- package/dist/esm/lib/postMessage.js +1 -1
- package/dist/esm/lib/postMessage.js.map +1 -1
- package/dist/esm/lib/windowUtil.d.ts.map +1 -1
- package/dist/esm/lib/windowUtil.js +1 -0
- package/dist/esm/lib/windowUtil.js.map +1 -1
- package/dist/esm/nextjs/config.d.ts.map +1 -1
- package/dist/esm/nextjs/config.js +12 -0
- package/dist/esm/nextjs/config.js.map +1 -1
- package/dist/esm/nextjs/hooks/index.d.ts +1 -1
- package/dist/esm/nextjs/hooks/index.d.ts.map +1 -1
- package/dist/esm/nextjs/hooks/index.js +1 -1
- package/dist/esm/nextjs/hooks/index.js.map +1 -1
- package/dist/esm/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/esm/nextjs/hooks/useUserCookie.js +45 -16
- package/dist/esm/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.d.ts +5 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.js +59 -30
- package/dist/esm/nextjs/providers/NextAuthProvider.js.map +1 -1
- package/dist/esm/reactjs/components/UserButton.js +3 -3
- package/dist/esm/reactjs/components/UserButton.js.map +1 -1
- package/dist/esm/reactjs/hooks/index.d.ts +0 -1
- package/dist/esm/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/esm/reactjs/hooks/index.js +0 -1
- package/dist/esm/reactjs/hooks/index.js.map +1 -1
- package/dist/esm/services/AuthenticationService.d.ts +4 -1
- package/dist/esm/services/AuthenticationService.d.ts.map +1 -1
- package/dist/esm/services/AuthenticationService.js +39 -8
- package/dist/esm/services/AuthenticationService.js.map +1 -1
- package/dist/esm/shared/components/BlockDisplay.d.ts +7 -0
- package/dist/esm/shared/components/BlockDisplay.d.ts.map +1 -0
- package/dist/esm/shared/components/BlockDisplay.js +25 -0
- package/dist/esm/shared/components/BlockDisplay.js.map +1 -0
- package/dist/esm/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/esm/shared/components/CivicAuthIframeContainer.js +23 -14
- package/dist/esm/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/esm/shared/components/IFrameAndLoading.d.ts +7 -0
- package/dist/esm/shared/components/IFrameAndLoading.d.ts.map +1 -0
- package/dist/esm/shared/components/IFrameAndLoading.js +22 -0
- package/dist/esm/shared/components/IFrameAndLoading.js.map +1 -0
- package/dist/esm/shared/hooks/index.d.ts +5 -1
- package/dist/esm/shared/hooks/index.d.ts.map +1 -1
- package/dist/esm/shared/hooks/index.js +5 -1
- package/dist/esm/shared/hooks/index.js.map +1 -1
- package/dist/esm/shared/hooks/useCivicAuthConfig.d.ts +3 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.js +10 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.js.map +1 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.d.ts +3 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.js +13 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.js.map +1 -0
- package/dist/esm/shared/hooks/useCurrentUrl.d.ts +3 -0
- package/dist/esm/shared/hooks/useCurrentUrl.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useCurrentUrl.js +24 -0
- package/dist/esm/shared/hooks/useCurrentUrl.js.map +1 -0
- package/dist/esm/shared/hooks/useIsInIframe.d.ts +3 -0
- package/dist/esm/shared/hooks/useIsInIframe.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useIsInIframe.js +14 -0
- package/dist/esm/shared/hooks/useIsInIframe.js.map +1 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.d.ts +4 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.js +14 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.js.map +1 -0
- package/dist/esm/shared/hooks/useRefresh.d.ts +4 -0
- package/dist/esm/shared/hooks/useRefresh.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useRefresh.js +38 -0
- package/dist/esm/shared/hooks/useRefresh.js.map +1 -0
- package/dist/esm/shared/hooks/useSession.d.ts +1 -1
- package/dist/esm/shared/hooks/useSession.d.ts.map +1 -1
- package/dist/esm/shared/hooks/useSignIn.d.ts +14 -0
- package/dist/esm/shared/hooks/useSignIn.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useSignIn.js +71 -0
- package/dist/esm/shared/hooks/useSignIn.js.map +1 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.d.ts +4 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.js +30 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/esm/shared/lib/types.d.ts +14 -1
- package/dist/esm/shared/lib/types.d.ts.map +1 -1
- package/dist/esm/shared/lib/types.js +2 -0
- package/dist/esm/shared/lib/types.js.map +1 -1
- package/dist/esm/shared/lib/util.d.ts.map +1 -1
- package/dist/esm/shared/lib/util.js +10 -2
- package/dist/esm/shared/lib/util.js.map +1 -1
- package/dist/esm/shared/providers/AuthProvider.d.ts +3 -2
- package/dist/esm/shared/providers/AuthProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/AuthProvider.js +37 -238
- package/dist/esm/shared/providers/AuthProvider.js.map +1 -1
- package/dist/esm/shared/providers/CivicAuthConfigContext.d.ts +16 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.d.ts.map +1 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.js +43 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.js.map +1 -0
- package/dist/esm/shared/providers/CivicAuthProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/CivicAuthProvider.js +23 -6
- package/dist/esm/shared/providers/CivicAuthProvider.js.map +1 -1
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.d.ts +17 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.d.ts.map +1 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.js +146 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.js.map +1 -0
- package/dist/esm/shared/providers/IframeProvider.d.ts +7 -4
- package/dist/esm/shared/providers/IframeProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/IframeProvider.js +21 -3
- package/dist/esm/shared/providers/IframeProvider.js.map +1 -1
- package/dist/esm/shared/providers/SessionProvider.d.ts +10 -4
- package/dist/esm/shared/providers/SessionProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/SessionProvider.js +15 -5
- package/dist/esm/shared/providers/SessionProvider.js.map +1 -1
- package/dist/esm/shared/providers/TokenProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/TokenProvider.js +13 -24
- package/dist/esm/shared/providers/TokenProvider.js.map +1 -1
- package/dist/esm/shared/providers/UserProvider.d.ts +4 -3
- package/dist/esm/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/UserProvider.js +30 -19
- package/dist/esm/shared/providers/UserProvider.js.map +1 -1
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/useUserCookie.js +45 -16
- package/dist/src/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -1
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -10
- package/.prettierignore +0 -3
- package/.prettierrc +0 -1
- package/.turbo/turbo-build.log +0 -13
- package/.turbo/turbo-lint$colon$fix.log +0 -10
- package/.turbo/turbo-test.log +0 -1153
- package/dist/cjs/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/cjs/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/cjs/nextjs/hooks/useTokenCookie.js +0 -41
- package/dist/cjs/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/cjs/shared/hooks/useConfig.d.ts +0 -3
- package/dist/cjs/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/cjs/shared/hooks/useConfig.js +0 -16
- package/dist/cjs/shared/hooks/useConfig.js.map +0 -1
- package/dist/cjs/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/cjs/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/cjs/shared/providers/ConfigProvider.js +0 -46
- package/dist/cjs/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/esm/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/esm/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/esm/nextjs/hooks/useTokenCookie.js +0 -37
- package/dist/esm/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/esm/shared/hooks/useConfig.d.ts +0 -3
- package/dist/esm/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/esm/shared/hooks/useConfig.js +0 -13
- package/dist/esm/shared/hooks/useConfig.js.map +0 -1
- package/dist/esm/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/esm/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/esm/shared/providers/ConfigProvider.js +0 -19
- package/dist/esm/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/src/browser/storage.d.ts +0 -6
- package/dist/src/browser/storage.d.ts.map +0 -1
- package/dist/src/browser/storage.js +0 -9
- package/dist/src/browser/storage.js.map +0 -1
- package/dist/src/config.d.ts +0 -3
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -5
- package/dist/src/config.js.map +0 -1
- package/dist/src/constants.d.ts +0 -9
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -17
- package/dist/src/constants.js.map +0 -1
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/lib/cookies.d.ts +0 -7
- package/dist/src/lib/cookies.d.ts.map +0 -1
- package/dist/src/lib/cookies.js +0 -23
- package/dist/src/lib/cookies.js.map +0 -1
- package/dist/src/lib/jwt.d.ts +0 -3
- package/dist/src/lib/jwt.d.ts.map +0 -1
- package/dist/src/lib/jwt.js +0 -9
- package/dist/src/lib/jwt.js.map +0 -1
- package/dist/src/lib/logger.d.ts +0 -26
- package/dist/src/lib/logger.d.ts.map +0 -1
- package/dist/src/lib/logger.js +0 -55
- package/dist/src/lib/logger.js.map +0 -1
- package/dist/src/lib/oauth.d.ts +0 -19
- package/dist/src/lib/oauth.d.ts.map +0 -1
- package/dist/src/lib/oauth.js +0 -60
- package/dist/src/lib/oauth.js.map +0 -1
- package/dist/src/lib/postMessage.d.ts +0 -4
- package/dist/src/lib/postMessage.d.ts.map +0 -1
- package/dist/src/lib/postMessage.js +0 -15
- package/dist/src/lib/postMessage.js.map +0 -1
- package/dist/src/lib/windowUtil.d.ts +0 -4
- package/dist/src/lib/windowUtil.d.ts.map +0 -1
- package/dist/src/lib/windowUtil.js +0 -30
- package/dist/src/lib/windowUtil.js.map +0 -1
- package/dist/src/nextjs/GetUser.d.ts +0 -6
- package/dist/src/nextjs/GetUser.d.ts.map +0 -1
- package/dist/src/nextjs/GetUser.js +0 -18
- package/dist/src/nextjs/GetUser.js.map +0 -1
- package/dist/src/nextjs/config.d.ts +0 -178
- package/dist/src/nextjs/config.d.ts.map +0 -1
- package/dist/src/nextjs/config.js +0 -161
- package/dist/src/nextjs/config.js.map +0 -1
- package/dist/src/nextjs/cookies.d.ts +0 -30
- package/dist/src/nextjs/cookies.d.ts.map +0 -1
- package/dist/src/nextjs/cookies.js +0 -112
- package/dist/src/nextjs/cookies.js.map +0 -1
- package/dist/src/nextjs/hooks/index.d.ts +0 -2
- package/dist/src/nextjs/hooks/index.d.ts.map +0 -1
- package/dist/src/nextjs/hooks/index.js +0 -2
- package/dist/src/nextjs/hooks/index.js.map +0 -1
- package/dist/src/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/src/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/src/nextjs/hooks/useTokenCookie.js +0 -37
- package/dist/src/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/src/nextjs/hooks/useUserCookie.d.ts +0 -3
- package/dist/src/nextjs/index.d.ts +0 -7
- package/dist/src/nextjs/index.d.ts.map +0 -1
- package/dist/src/nextjs/index.js +0 -6
- package/dist/src/nextjs/index.js.map +0 -1
- package/dist/src/nextjs/middleware/index.d.ts +0 -2
- package/dist/src/nextjs/middleware/index.d.ts.map +0 -1
- package/dist/src/nextjs/middleware/index.js +0 -2
- package/dist/src/nextjs/middleware/index.js.map +0 -1
- package/dist/src/nextjs/middleware.d.ts +0 -59
- package/dist/src/nextjs/middleware.d.ts.map +0 -1
- package/dist/src/nextjs/middleware.js +0 -107
- package/dist/src/nextjs/middleware.js.map +0 -1
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts +0 -9
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts.map +0 -1
- package/dist/src/nextjs/providers/NextAuthProvider.js +0 -50
- package/dist/src/nextjs/providers/NextAuthProvider.js.map +0 -1
- package/dist/src/nextjs/routeHandler.d.ts +0 -18
- package/dist/src/nextjs/routeHandler.d.ts.map +0 -1
- package/dist/src/nextjs/routeHandler.js +0 -212
- package/dist/src/nextjs/routeHandler.js.map +0 -1
- package/dist/src/nextjs/utils.d.ts +0 -3
- package/dist/src/nextjs/utils.d.ts.map +0 -1
- package/dist/src/nextjs/utils.js +0 -5
- package/dist/src/nextjs/utils.js.map +0 -1
- package/dist/src/reactjs/components/SignInButton.d.ts +0 -8
- package/dist/src/reactjs/components/SignInButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/SignInButton.js +0 -14
- package/dist/src/reactjs/components/SignInButton.js.map +0 -1
- package/dist/src/reactjs/components/SignOutButton.d.ts +0 -6
- package/dist/src/reactjs/components/SignOutButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/SignOutButton.js +0 -14
- package/dist/src/reactjs/components/SignOutButton.js.map +0 -1
- package/dist/src/reactjs/components/UserButton.d.ts +0 -8
- package/dist/src/reactjs/components/UserButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/UserButton.js +0 -118
- package/dist/src/reactjs/components/UserButton.js.map +0 -1
- package/dist/src/reactjs/components/index.d.ts +0 -6
- package/dist/src/reactjs/components/index.d.ts.map +0 -1
- package/dist/src/reactjs/components/index.js +0 -6
- package/dist/src/reactjs/components/index.js.map +0 -1
- package/dist/src/reactjs/hooks/index.d.ts +0 -7
- package/dist/src/reactjs/hooks/index.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/index.js +0 -7
- package/dist/src/reactjs/hooks/index.js.map +0 -1
- package/dist/src/reactjs/hooks/useAuth.d.ts +0 -3
- package/dist/src/reactjs/hooks/useAuth.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/useAuth.js +0 -12
- package/dist/src/reactjs/hooks/useAuth.js.map +0 -1
- package/dist/src/reactjs/hooks/useUser.d.ts +0 -4
- package/dist/src/reactjs/hooks/useUser.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/useUser.js +0 -12
- package/dist/src/reactjs/hooks/useUser.js.map +0 -1
- package/dist/src/reactjs/index.d.ts +0 -6
- package/dist/src/reactjs/index.d.ts.map +0 -1
- package/dist/src/reactjs/index.js +0 -8
- package/dist/src/reactjs/index.js.map +0 -1
- package/dist/src/reactjs/providers/index.d.ts +0 -8
- package/dist/src/reactjs/providers/index.d.ts.map +0 -1
- package/dist/src/reactjs/providers/index.js +0 -7
- package/dist/src/reactjs/providers/index.js.map +0 -1
- package/dist/src/server/ServerAuthenticationResolver.d.ts +0 -19
- package/dist/src/server/ServerAuthenticationResolver.d.ts.map +0 -1
- package/dist/src/server/ServerAuthenticationResolver.js +0 -61
- package/dist/src/server/ServerAuthenticationResolver.js.map +0 -1
- package/dist/src/server/config.d.ts +0 -9
- package/dist/src/server/config.d.ts.map +0 -1
- package/dist/src/server/config.js +0 -2
- package/dist/src/server/config.js.map +0 -1
- package/dist/src/server/index.d.ts +0 -7
- package/dist/src/server/index.d.ts.map +0 -1
- package/dist/src/server/index.js +0 -5
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/login.d.ts +0 -17
- package/dist/src/server/login.d.ts.map +0 -1
- package/dist/src/server/login.js +0 -37
- package/dist/src/server/login.js.map +0 -1
- package/dist/src/server/refresh.d.ts +0 -7
- package/dist/src/server/refresh.d.ts.map +0 -1
- package/dist/src/server/refresh.js +0 -13
- package/dist/src/server/refresh.js.map +0 -1
- package/dist/src/services/AuthenticationService.d.ts +0 -87
- package/dist/src/services/AuthenticationService.d.ts.map +0 -1
- package/dist/src/services/AuthenticationService.js +0 -212
- package/dist/src/services/AuthenticationService.js.map +0 -1
- package/dist/src/services/PKCE.d.ts +0 -20
- package/dist/src/services/PKCE.d.ts.map +0 -1
- package/dist/src/services/PKCE.js +0 -44
- package/dist/src/services/PKCE.js.map +0 -1
- package/dist/src/services/types.d.ts +0 -23
- package/dist/src/services/types.d.ts.map +0 -1
- package/dist/src/services/types.js +0 -7
- package/dist/src/services/types.js.map +0 -1
- package/dist/src/shared/components/CivicAuthIframe.d.ts +0 -8
- package/dist/src/shared/components/CivicAuthIframe.d.ts.map +0 -1
- package/dist/src/shared/components/CivicAuthIframe.js +0 -9
- package/dist/src/shared/components/CivicAuthIframe.js.map +0 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.d.ts +0 -9
- package/dist/src/shared/components/CivicAuthIframeContainer.d.ts.map +0 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.js +0 -129
- package/dist/src/shared/components/CivicAuthIframeContainer.js.map +0 -1
- package/dist/src/shared/components/CloseIcon.d.ts +0 -4
- package/dist/src/shared/components/CloseIcon.d.ts.map +0 -1
- package/dist/src/shared/components/CloseIcon.js +0 -6
- package/dist/src/shared/components/CloseIcon.js.map +0 -1
- package/dist/src/shared/components/LoadingIcon.d.ts +0 -4
- package/dist/src/shared/components/LoadingIcon.d.ts.map +0 -1
- package/dist/src/shared/components/LoadingIcon.js +0 -30
- package/dist/src/shared/components/LoadingIcon.js.map +0 -1
- package/dist/src/shared/hooks/index.d.ts +0 -5
- package/dist/src/shared/hooks/index.d.ts.map +0 -1
- package/dist/src/shared/hooks/index.js +0 -5
- package/dist/src/shared/hooks/index.js.map +0 -1
- package/dist/src/shared/hooks/useAuth.d.ts +0 -3
- package/dist/src/shared/hooks/useAuth.d.ts.map +0 -1
- package/dist/src/shared/hooks/useAuth.js +0 -12
- package/dist/src/shared/hooks/useAuth.js.map +0 -1
- package/dist/src/shared/hooks/useConfig.d.ts +0 -3
- package/dist/src/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/src/shared/hooks/useConfig.js +0 -13
- package/dist/src/shared/hooks/useConfig.js.map +0 -1
- package/dist/src/shared/hooks/useIframe.d.ts +0 -3
- package/dist/src/shared/hooks/useIframe.d.ts.map +0 -1
- package/dist/src/shared/hooks/useIframe.js +0 -13
- package/dist/src/shared/hooks/useIframe.js.map +0 -1
- package/dist/src/shared/hooks/useSession.d.ts +0 -3
- package/dist/src/shared/hooks/useSession.d.ts.map +0 -1
- package/dist/src/shared/hooks/useSession.js +0 -13
- package/dist/src/shared/hooks/useSession.js.map +0 -1
- package/dist/src/shared/hooks/useToken.d.ts +0 -3
- package/dist/src/shared/hooks/useToken.d.ts.map +0 -1
- package/dist/src/shared/hooks/useToken.js +0 -12
- package/dist/src/shared/hooks/useToken.js.map +0 -1
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts +0 -16
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts.map +0 -1
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js +0 -43
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js.map +0 -1
- package/dist/src/shared/lib/UserSession.d.ts +0 -12
- package/dist/src/shared/lib/UserSession.d.ts.map +0 -1
- package/dist/src/shared/lib/UserSession.js +0 -20
- package/dist/src/shared/lib/UserSession.js.map +0 -1
- package/dist/src/shared/lib/session.d.ts +0 -3
- package/dist/src/shared/lib/session.d.ts.map +0 -1
- package/dist/src/shared/lib/session.js +0 -10
- package/dist/src/shared/lib/session.js.map +0 -1
- package/dist/src/shared/lib/storage.d.ts +0 -25
- package/dist/src/shared/lib/storage.d.ts.map +0 -1
- package/dist/src/shared/lib/storage.js +0 -17
- package/dist/src/shared/lib/storage.js.map +0 -1
- package/dist/src/shared/lib/types.d.ts +0 -22
- package/dist/src/shared/lib/types.d.ts.map +0 -1
- package/dist/src/shared/lib/types.js +0 -16
- package/dist/src/shared/lib/types.js.map +0 -1
- package/dist/src/shared/lib/util.d.ts +0 -33
- package/dist/src/shared/lib/util.d.ts.map +0 -1
- package/dist/src/shared/lib/util.js +0 -124
- package/dist/src/shared/lib/util.js.map +0 -1
- package/dist/src/shared/providers/AuthContext.d.ts +0 -10
- package/dist/src/shared/providers/AuthContext.d.ts.map +0 -1
- package/dist/src/shared/providers/AuthContext.js +0 -3
- package/dist/src/shared/providers/AuthContext.js.map +0 -1
- package/dist/src/shared/providers/AuthProvider.d.ts +0 -20
- package/dist/src/shared/providers/AuthProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/AuthProvider.js +0 -264
- package/dist/src/shared/providers/AuthProvider.js.map +0 -1
- package/dist/src/shared/providers/CivicAuthProvider.d.ts +0 -6
- package/dist/src/shared/providers/CivicAuthProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/CivicAuthProvider.js +0 -15
- package/dist/src/shared/providers/CivicAuthProvider.js.map +0 -1
- package/dist/src/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/src/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/ConfigProvider.js +0 -19
- package/dist/src/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/src/shared/providers/IframeProvider.d.ts +0 -16
- package/dist/src/shared/providers/IframeProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/IframeProvider.js +0 -11
- package/dist/src/shared/providers/IframeProvider.js.map +0 -1
- package/dist/src/shared/providers/SessionProvider.d.ts +0 -13
- package/dist/src/shared/providers/SessionProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/SessionProvider.js +0 -13
- package/dist/src/shared/providers/SessionProvider.js.map +0 -1
- package/dist/src/shared/providers/TokenProvider.d.ts +0 -18
- package/dist/src/shared/providers/TokenProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/TokenProvider.js +0 -53
- package/dist/src/shared/providers/TokenProvider.js.map +0 -1
- package/dist/src/shared/providers/UserProvider.d.ts +0 -18
- package/dist/src/shared/providers/UserProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/UserProvider.js +0 -38
- package/dist/src/shared/providers/UserProvider.js.map +0 -1
- package/dist/src/types.d.ts +0 -146
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -15
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -43
- package/dist/src/utils.js.map +0 -1
- package/dist/test/integration/sdk.test.d.ts +0 -2
- package/dist/test/integration/sdk.test.d.ts.map +0 -1
- package/dist/test/integration/sdk.test.js +0 -183
- package/dist/test/integration/sdk.test.js.map +0 -1
- package/dist/test/support/fixtures.d.ts +0 -26
- package/dist/test/support/fixtures.d.ts.map +0 -1
- package/dist/test/support/fixtures.js +0 -55
- package/dist/test/support/fixtures.js.map +0 -1
- package/dist/test/support/tokens.json +0 -26
- package/dist/test/unit/lib/oauth.test.d.ts +0 -2
- package/dist/test/unit/lib/oauth.test.d.ts.map +0 -1
- package/dist/test/unit/lib/oauth.test.js +0 -55
- package/dist/test/unit/lib/oauth.test.js.map +0 -1
- package/dist/test/unit/logger.test.d.ts +0 -2
- package/dist/test/unit/logger.test.d.ts.map +0 -1
- package/dist/test/unit/logger.test.js +0 -141
- package/dist/test/unit/logger.test.js.map +0 -1
- package/dist/test/unit/nextjs/NextAuthProvider.test.d.ts +0 -2
- package/dist/test/unit/nextjs/NextAuthProvider.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/NextAuthProvider.test.js +0 -29
- package/dist/test/unit/nextjs/NextAuthProvider.test.js.map +0 -1
- package/dist/test/unit/nextjs/config.test.d.ts +0 -2
- package/dist/test/unit/nextjs/config.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/config.test.js +0 -189
- package/dist/test/unit/nextjs/config.test.js.map +0 -1
- package/dist/test/unit/nextjs/getUser.test.d.ts +0 -2
- package/dist/test/unit/nextjs/getUser.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/getUser.test.js +0 -36
- package/dist/test/unit/nextjs/getUser.test.js.map +0 -1
- package/dist/test/unit/nextjs/middleware.test.d.ts +0 -2
- package/dist/test/unit/nextjs/middleware.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/middleware.test.js +0 -113
- package/dist/test/unit/nextjs/middleware.test.js.map +0 -1
- package/dist/test/unit/nextjs/utils.test.d.ts +0 -2
- package/dist/test/unit/nextjs/utils.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/utils.test.js +0 -13
- package/dist/test/unit/nextjs/utils.test.js.map +0 -1
- package/dist/test/unit/publicApi/apiSnapshot.test.d.ts +0 -2
- package/dist/test/unit/publicApi/apiSnapshot.test.d.ts.map +0 -1
- package/dist/test/unit/publicApi/apiSnapshot.test.js +0 -10
- package/dist/test/unit/publicApi/apiSnapshot.test.js.map +0 -1
- package/dist/test/unit/react/components/SignInButton.test.d.ts +0 -2
- package/dist/test/unit/react/components/SignInButton.test.d.ts.map +0 -1
- package/dist/test/unit/react/components/SignInButton.test.js +0 -31
- package/dist/test/unit/react/components/SignInButton.test.js.map +0 -1
- package/dist/test/unit/react/components/SignOutButton.test.d.ts +0 -2
- package/dist/test/unit/react/components/SignOutButton.test.d.ts.map +0 -1
- package/dist/test/unit/react/components/SignOutButton.test.js +0 -30
- package/dist/test/unit/react/components/SignOutButton.test.js.map +0 -1
- package/dist/test/unit/server/login.test.d.ts +0 -2
- package/dist/test/unit/server/login.test.d.ts.map +0 -1
- package/dist/test/unit/server/login.test.js +0 -127
- package/dist/test/unit/server/login.test.js.map +0 -1
- package/dist/test/unit/server/session.test.d.ts +0 -2
- package/dist/test/unit/server/session.test.d.ts.map +0 -1
- package/dist/test/unit/server/session.test.js +0 -41
- package/dist/test/unit/server/session.test.js.map +0 -1
- package/dist/test/unit/services/AuthenticationService.test.d.ts +0 -2
- package/dist/test/unit/services/AuthenticationService.test.d.ts.map +0 -1
- package/dist/test/unit/services/AuthenticationService.test.js +0 -104
- package/dist/test/unit/services/AuthenticationService.test.js.map +0 -1
- package/dist/test/unit/services/ServerAuthenticationResolver.test.d.ts +0 -2
- package/dist/test/unit/services/ServerAuthenticationResolver.test.d.ts.map +0 -1
- package/dist/test/unit/services/ServerAuthenticationResolver.test.js +0 -74
- package/dist/test/unit/services/ServerAuthenticationResolver.test.js.map +0 -1
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.d.ts +0 -2
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.d.ts.map +0 -1
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.js +0 -61
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.js.map +0 -1
- package/dist/test/unit/shared/UserSession.test.d.ts +0 -2
- package/dist/test/unit/shared/UserSession.test.d.ts.map +0 -1
- package/dist/test/unit/shared/UserSession.test.js +0 -37
- package/dist/test/unit/shared/UserSession.test.js.map +0 -1
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.d.ts +0 -2
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.d.ts.map +0 -1
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.js +0 -120
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.js.map +0 -1
- package/dist/test/unit/shared/storage.test.d.ts +0 -2
- package/dist/test/unit/shared/storage.test.d.ts.map +0 -1
- package/dist/test/unit/shared/storage.test.js +0 -53
- package/dist/test/unit/shared/storage.test.js.map +0 -1
- package/dist/test/unit/utils.test.d.ts +0 -2
- package/dist/test/unit/utils.test.d.ts.map +0 -1
- package/dist/test/unit/utils.test.js +0 -40
- package/dist/test/unit/utils.test.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -40
- package/dist/vitest.config.js.map +0 -1
- package/src/browser/storage.ts +0 -11
- package/src/config.ts +0 -6
- package/src/constants.ts +0 -29
- package/src/index.ts +0 -16
- package/src/lib/cookies.ts +0 -28
- package/src/lib/jwt.ts +0 -15
- package/src/lib/logger.ts +0 -72
- package/src/lib/oauth.ts +0 -83
- package/src/lib/postMessage.ts +0 -22
- package/src/lib/windowUtil.ts +0 -29
- package/src/nextjs/GetUser.ts +0 -22
- package/src/nextjs/config.ts +0 -203
- package/src/nextjs/cookies.ts +0 -162
- package/src/nextjs/hooks/index.ts +0 -1
- package/src/nextjs/hooks/useTokenCookie.ts +0 -41
- package/src/nextjs/hooks/useUserCookie.ts +0 -41
- package/src/nextjs/index.ts +0 -20
- package/src/nextjs/middleware/index.ts +0 -1
- package/src/nextjs/middleware.ts +0 -155
- package/src/nextjs/providers/NextAuthProvider.tsx +0 -87
- package/src/nextjs/routeHandler.ts +0 -297
- package/src/nextjs/utils.ts +0 -9
- package/src/reactjs/components/SignInButton.tsx +0 -32
- package/src/reactjs/components/SignOutButton.tsx +0 -24
- package/src/reactjs/components/UserButton.tsx +0 -239
- package/src/reactjs/components/index.ts +0 -5
- package/src/reactjs/hooks/index.ts +0 -6
- package/src/reactjs/hooks/useAuth.ts +0 -15
- package/src/reactjs/hooks/useUser.ts +0 -20
- package/src/reactjs/index.ts +0 -19
- package/src/reactjs/providers/index.ts +0 -27
- package/src/server/ServerAuthenticationResolver.ts +0 -107
- package/src/server/config.ts +0 -9
- package/src/server/index.ts +0 -13
- package/src/server/login.ts +0 -59
- package/src/server/refresh.ts +0 -23
- package/src/services/AuthenticationService.ts +0 -329
- package/src/services/PKCE.ts +0 -45
- package/src/services/types.ts +0 -54
- package/src/shared/components/CivicAuthIframe.tsx +0 -26
- package/src/shared/components/CivicAuthIframeContainer.tsx +0 -195
- package/src/shared/components/CloseIcon.tsx +0 -21
- package/src/shared/components/LoadingIcon.tsx +0 -53
- package/src/shared/hooks/index.ts +0 -4
- package/src/shared/hooks/useAuth.ts +0 -15
- package/src/shared/hooks/useConfig.ts +0 -14
- package/src/shared/hooks/useIframe.ts +0 -14
- package/src/shared/hooks/useSession.ts +0 -14
- package/src/shared/hooks/useToken.ts +0 -15
- package/src/shared/lib/GenericAuthenticationRefresher.ts +0 -75
- package/src/shared/lib/UserSession.ts +0 -25
- package/src/shared/lib/session.ts +0 -11
- package/src/shared/lib/storage.ts +0 -40
- package/src/shared/lib/types.ts +0 -26
- package/src/shared/lib/util.ts +0 -212
- package/src/shared/providers/AuthContext.tsx +0 -11
- package/src/shared/providers/AuthProvider.tsx +0 -397
- package/src/shared/providers/CivicAuthProvider.tsx +0 -31
- package/src/shared/providers/ConfigProvider.tsx +0 -50
- package/src/shared/providers/IframeProvider.tsx +0 -34
- package/src/shared/providers/SessionProvider.tsx +0 -29
- package/src/shared/providers/TokenProvider.tsx +0 -78
- package/src/shared/providers/UserProvider.tsx +0 -80
- package/src/types.ts +0 -227
- package/src/utils.ts +0 -58
- package/test/integration/sdk.test.tsx +0 -266
- package/test/support/fixtures.ts +0 -56
- package/test/support/tokens.json +0 -26
- package/test/unit/lib/oauth.test.ts +0 -72
- package/test/unit/logger.test.ts +0 -175
- package/test/unit/nextjs/NextAuthProvider.test.tsx +0 -38
- package/test/unit/nextjs/config.test.ts +0 -218
- package/test/unit/nextjs/getUser.test.ts +0 -41
- package/test/unit/nextjs/middleware.test.ts +0 -138
- package/test/unit/nextjs/routeHandler.test.ts.skipped +0 -369
- package/test/unit/nextjs/utils.test.ts +0 -17
- package/test/unit/publicApi/__snapshots__/apiSnapshot.test.ts.snap +0 -17
- package/test/unit/publicApi/apiSnapshot.test.ts +0 -11
- package/test/unit/react/components/SignInButton.test.tsx +0 -50
- package/test/unit/react/components/SignOutButton.test.tsx +0 -49
- package/test/unit/server/login.test.ts +0 -181
- package/test/unit/server/session.test.ts +0 -51
- package/test/unit/services/AuthenticationService.test.ts +0 -152
- package/test/unit/services/ServerAuthenticationResolver.test.ts +0 -115
- package/test/unit/shared/GenericAuthenticationRefresher.test.ts +0 -89
- package/test/unit/shared/UserSession.test.ts +0 -42
- package/test/unit/shared/components/CivicAuthIframeContainer.test.tsx +0 -154
- package/test/unit/shared/storage.test.ts +0 -67
- package/test/unit/utils.test.ts +0 -48
- package/tsconfig.build.json +0 -9
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -7
- package/tsconfig.json +0 -42
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -41
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, vi } from "vitest";
|
|
2
|
-
import { NextRequest, NextResponse } from "next/server.js";
|
|
3
|
-
import { handler } from "@/nextjs/routeHandler.js";
|
|
4
|
-
import { revalidatePath } from "next/cache.js";
|
|
5
|
-
import type { OIDCTokenResponseBody, User } from "@/types.ts";
|
|
6
|
-
import * as logger from "@/lib/logger.js";
|
|
7
|
-
import * as login from "@/server/login.js";
|
|
8
|
-
import * as session from "@/shared/lib/session.js";
|
|
9
|
-
import * as cookies from "@/nextjs/cookies.js";
|
|
10
|
-
import * as PKCE from "@/services/PKCE.js";
|
|
11
|
-
import { GenericUserSession } from "@/shared/lib/UserSession.js";
|
|
12
|
-
import { TOKEN_EXCHANGE_TRIGGER_TEXT } from "@/constants.js";
|
|
13
|
-
|
|
14
|
-
vi.mock("next/headers.js", () => {
|
|
15
|
-
return {
|
|
16
|
-
cookies: vi.fn().mockReturnValue({
|
|
17
|
-
set: vi.fn(),
|
|
18
|
-
get: (name: string) => {
|
|
19
|
-
if (name === "codeVerifier") {
|
|
20
|
-
return "test-code-verifier";
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
vi.mock("@/server/login.js");
|
|
28
|
-
vi.mock("@/shared/lib/session.js");
|
|
29
|
-
vi.mock("@/nextjs/cookies.js");
|
|
30
|
-
vi.mock("@/services/PKCE.js");
|
|
31
|
-
|
|
32
|
-
const mockUser: User = {
|
|
33
|
-
id: "user123",
|
|
34
|
-
name: "John Doe",
|
|
35
|
-
email: "john@example.com",
|
|
36
|
-
picture: "https://example.com/john.jpg",
|
|
37
|
-
} as unknown as User;
|
|
38
|
-
|
|
39
|
-
// Mock implementations
|
|
40
|
-
vi.mock("next/server.js", () => {
|
|
41
|
-
class MockNextResponse {
|
|
42
|
-
constructor(
|
|
43
|
-
public body?: any,
|
|
44
|
-
public init?: any,
|
|
45
|
-
) {
|
|
46
|
-
this.body = body;
|
|
47
|
-
this.init = init;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public headers = {
|
|
51
|
-
set: vi.fn(),
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
public cookies = {
|
|
55
|
-
set: vi.fn(),
|
|
56
|
-
get: vi.fn(),
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
json() {
|
|
60
|
-
return Promise.resolve({});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static json(data: any, options: any) {
|
|
64
|
-
return {
|
|
65
|
-
...options,
|
|
66
|
-
data,
|
|
67
|
-
json: () => Promise.resolve(data),
|
|
68
|
-
headers: {
|
|
69
|
-
set: vi.fn(),
|
|
70
|
-
},
|
|
71
|
-
cookies: {
|
|
72
|
-
set: vi.fn(),
|
|
73
|
-
get: vi.fn(),
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static redirect(url: string) {
|
|
79
|
-
return {
|
|
80
|
-
url,
|
|
81
|
-
cookies: {
|
|
82
|
-
set: vi.fn(),
|
|
83
|
-
get: vi.fn(),
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
NextResponse: MockNextResponse,
|
|
91
|
-
NextRequest: vi.fn().mockImplementation((url) => ({
|
|
92
|
-
url,
|
|
93
|
-
nextUrl: new URL(url),
|
|
94
|
-
})),
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
vi.mock("next/cache", () => ({
|
|
99
|
-
revalidatePath: vi.fn(),
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
describe.skip("Auth Route Handler", () => {
|
|
103
|
-
let mockLogger: logger.Logger;
|
|
104
|
-
afterEach(vi.clearAllMocks);
|
|
105
|
-
beforeEach(() => {
|
|
106
|
-
mockLogger = {
|
|
107
|
-
error: vi.fn(),
|
|
108
|
-
info: vi.fn(),
|
|
109
|
-
warn: vi.fn(),
|
|
110
|
-
debug: vi.fn(),
|
|
111
|
-
};
|
|
112
|
-
vi.spyOn(logger.loggers.nextjs.handlers.auth, "debug").mockImplementation(
|
|
113
|
-
(...args) => mockLogger.debug(...args),
|
|
114
|
-
);
|
|
115
|
-
vi.spyOn(logger.loggers.nextjs.handlers.auth, "info").mockImplementation(
|
|
116
|
-
(...args) => mockLogger.info(...args),
|
|
117
|
-
);
|
|
118
|
-
vi.spyOn(logger.loggers.nextjs.handlers.auth, "warn").mockImplementation(
|
|
119
|
-
(...args) => mockLogger.warn(...args),
|
|
120
|
-
);
|
|
121
|
-
vi.spyOn(logger.loggers.nextjs.handlers.auth, "error").mockImplementation(
|
|
122
|
-
(...args) => mockLogger.error(...args),
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
beforeEach(() => {
|
|
127
|
-
vi.clearAllMocks();
|
|
128
|
-
vi.stubEnv("_civic_auth_client_id", "test-client-id");
|
|
129
|
-
vi.spyOn(login, "resolveOAuthAccessCode").mockResolvedValue(
|
|
130
|
-
{} as OIDCTokenResponseBody,
|
|
131
|
-
);
|
|
132
|
-
vi.spyOn(session, "getUser").mockResolvedValue(mockUser);
|
|
133
|
-
vi.spyOn(GenericUserSession.prototype, "set");
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe("Challenge Handler", () => {
|
|
137
|
-
beforeEach(() => {
|
|
138
|
-
vi.spyOn(
|
|
139
|
-
PKCE.GenericPublicClientPKCEProducer.prototype,
|
|
140
|
-
"getCodeChallenge",
|
|
141
|
-
).mockResolvedValue("test-code-challenge");
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("should handle challenge request", async () => {
|
|
145
|
-
const mockRequest = new NextRequest(
|
|
146
|
-
"https://example.com/api/auth/challenge",
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const routeHandler = handler();
|
|
150
|
-
const response = await routeHandler(mockRequest);
|
|
151
|
-
|
|
152
|
-
expect(response.json()).resolves.toEqual({
|
|
153
|
-
status: "success",
|
|
154
|
-
challenge: "test-code-challenge",
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe("Callback Handler", () => {
|
|
160
|
-
let mockRequest: NextRequest;
|
|
161
|
-
let routeHandler: (request: NextRequest) => Promise<NextResponse>;
|
|
162
|
-
beforeAll(() => {
|
|
163
|
-
routeHandler = handler();
|
|
164
|
-
});
|
|
165
|
-
it("should handle missing parameters", async () => {
|
|
166
|
-
mockRequest = new NextRequest(
|
|
167
|
-
"https://example.com/api/auth/callback", // missing params
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
(mockRequest as unknown as Record<string, unknown>).cookies = {
|
|
171
|
-
get: (cookieName: string) =>
|
|
172
|
-
cookieName === "code_verifier" ? "test-code-verifier" : undefined,
|
|
173
|
-
};
|
|
174
|
-
const response = await routeHandler(mockRequest);
|
|
175
|
-
|
|
176
|
-
expect(response.json()).resolves.toEqual({
|
|
177
|
-
error: "Bad parameters",
|
|
178
|
-
});
|
|
179
|
-
expect(response.status).toBe(400);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
describe("with all parameters passed in", () => {
|
|
183
|
-
beforeAll(() => {
|
|
184
|
-
mockRequest = new NextRequest(
|
|
185
|
-
"https://example.com/api/auth/callback?code=123&state=testState&appUrl=https://example.com",
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
(mockRequest as unknown as Record<string, unknown>).cookies = {
|
|
189
|
-
get: (cookieName: string) =>
|
|
190
|
-
cookieName === "code_verifier" ? "test-code-verifier" : undefined,
|
|
191
|
-
};
|
|
192
|
-
});
|
|
193
|
-
it("should handle error when resolving the access code", async () => {
|
|
194
|
-
vi.spyOn(login, "resolveOAuthAccessCode").mockRejectedValue(
|
|
195
|
-
"Token exchange failed",
|
|
196
|
-
);
|
|
197
|
-
const response = await routeHandler(mockRequest);
|
|
198
|
-
|
|
199
|
-
expect(response.json()).resolves.toEqual({
|
|
200
|
-
error: "Failed to authenticate user",
|
|
201
|
-
});
|
|
202
|
-
expect(response.status).toBe(401);
|
|
203
|
-
});
|
|
204
|
-
describe("with code_verifier cookie present on request", () => {
|
|
205
|
-
it("should do token exchange", async () => {
|
|
206
|
-
const routeHandler = handler();
|
|
207
|
-
const response = await routeHandler(mockRequest);
|
|
208
|
-
|
|
209
|
-
// should have resolved the access code
|
|
210
|
-
expect(login.resolveOAuthAccessCode).toHaveBeenCalled();
|
|
211
|
-
|
|
212
|
-
// verify response data
|
|
213
|
-
const responseData = await response.json();
|
|
214
|
-
expect(responseData).toEqual({});
|
|
215
|
-
|
|
216
|
-
// verify user is being set to the session
|
|
217
|
-
expect(GenericUserSession.prototype.set).toHaveBeenCalledWith(
|
|
218
|
-
mockUser,
|
|
219
|
-
);
|
|
220
|
-
});
|
|
221
|
-
it("should return empty html response", async () => {
|
|
222
|
-
const response = await routeHandler(mockRequest);
|
|
223
|
-
expect(response.body).toEqual(
|
|
224
|
-
'<html><span style="display:none">serverSideTokenExchangeSuccess</span></html>',
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
describe("with no code_verifier cookie present on request", () => {
|
|
229
|
-
beforeAll(() => {
|
|
230
|
-
(mockRequest as unknown as Record<string, unknown>).cookies = {
|
|
231
|
-
get: () => undefined,
|
|
232
|
-
};
|
|
233
|
-
});
|
|
234
|
-
it("should not do token exchange", async () => {
|
|
235
|
-
const response = await routeHandler(mockRequest);
|
|
236
|
-
|
|
237
|
-
// should have resolved the access code
|
|
238
|
-
expect(login.resolveOAuthAccessCode).not.toHaveBeenCalled();
|
|
239
|
-
|
|
240
|
-
// verify response data
|
|
241
|
-
const responseData = await response.json();
|
|
242
|
-
expect(responseData).toEqual({});
|
|
243
|
-
|
|
244
|
-
// verify user is being set to the session
|
|
245
|
-
expect(GenericUserSession.prototype.set).not.toHaveBeenCalled();
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
describe("in server token-exchange mode", () => {
|
|
249
|
-
let state: string;
|
|
250
|
-
beforeEach(() => {
|
|
251
|
-
state =
|
|
252
|
-
"eyJ1dWlkIjoiMGY0NWU5YWItY2U1Ni00OWZiLTlkYmUtOGQ3ZmM3YTI3NDFhIiwiZGlzcGxheU1vZGUiOiJpZnJhbWUiLCJzZXJ2ZXJUb2tlbkV4Y2hhbmdlIjp0cnVlfQ";
|
|
253
|
-
const params = new URLSearchParams({ code: "123", state });
|
|
254
|
-
mockRequest = new NextRequest(
|
|
255
|
-
`https://example.com/api/auth/callback?${params.toString()}`,
|
|
256
|
-
);
|
|
257
|
-
(mockRequest as unknown as Record<string, unknown>).cookies = {
|
|
258
|
-
get: () => undefined,
|
|
259
|
-
};
|
|
260
|
-
});
|
|
261
|
-
it("should return html with a javascript fetch call to retry the callback token exchange", async () => {
|
|
262
|
-
// this state indicates server-side token exchange
|
|
263
|
-
|
|
264
|
-
const response = await routeHandler(mockRequest);
|
|
265
|
-
|
|
266
|
-
expect(response.body).toContain(
|
|
267
|
-
`fetch('/api/auth/callback?code=123&state=${state}&sameDomainServerTokenExchange=true&appUrl=' + appUrl)`,
|
|
268
|
-
);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe("in client token-exchange mode", () => {
|
|
273
|
-
let state: string;
|
|
274
|
-
beforeEach(() => {
|
|
275
|
-
state =
|
|
276
|
-
"eyJ1dWlkIjoiNzE5MmI3MmItYzk5ZC00NjhmLTliMDAtMWFhOWVhYjI0YjgxIiwiZGlzcGxheU1vZGUiOiJyZWRpcmVjdCJ9";
|
|
277
|
-
const params = new URLSearchParams({ code: "123", state });
|
|
278
|
-
mockRequest = new NextRequest(
|
|
279
|
-
`https://example.com/api/auth/callback?${params.toString()}`,
|
|
280
|
-
);
|
|
281
|
-
(mockRequest as unknown as Record<string, unknown>).cookies = {
|
|
282
|
-
get: () => undefined,
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
it("should return html response indicating a token exchange is required", async () => {
|
|
286
|
-
const response = await routeHandler(mockRequest);
|
|
287
|
-
expect(response.body).toEqual(
|
|
288
|
-
`<html><body><span style="display:none">${TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`,
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe("Logout Handler", () => {
|
|
297
|
-
beforeEach(() => {
|
|
298
|
-
vi.spyOn(cookies, "clearAuthCookies");
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it("should clear auth cookies", async () => {
|
|
302
|
-
const mockRequest = new NextRequest(
|
|
303
|
-
"https://example.com/api/auth/logout?redirect=/dashboard",
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
const routeHandler = handler();
|
|
307
|
-
|
|
308
|
-
await routeHandler(mockRequest);
|
|
309
|
-
expect(cookies.clearAuthCookies).toHaveBeenCalled();
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("should handle relative redirect paths", async () => {
|
|
313
|
-
const mockRequest = new NextRequest(
|
|
314
|
-
"https://example.com/api/auth/logout?redirect=/dashboard",
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
const routeHandler = handler();
|
|
318
|
-
|
|
319
|
-
const response = await routeHandler(mockRequest);
|
|
320
|
-
|
|
321
|
-
expect(response.url).toBe("https://example.com/dashboard");
|
|
322
|
-
expect(revalidatePath).toHaveBeenCalledWith("/dashboard");
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
it("should handle default redirect to home", async () => {
|
|
326
|
-
const mockRequest = new NextRequest(
|
|
327
|
-
"https://example.com/api/auth/logout",
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
const routeHandler = handler();
|
|
331
|
-
|
|
332
|
-
const response = await routeHandler(mockRequest);
|
|
333
|
-
|
|
334
|
-
expect(response.url).toBe("https://example.com/");
|
|
335
|
-
expect(revalidatePath).toHaveBeenCalledWith("/");
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it("should handle absolute URLs and preserve the domain", async () => {
|
|
339
|
-
const mockRequest = new NextRequest(
|
|
340
|
-
"https://example.com/api/auth/logout?redirect=https://other-domain.com/page",
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
const routeHandler = handler();
|
|
344
|
-
|
|
345
|
-
const response = await routeHandler(mockRequest);
|
|
346
|
-
|
|
347
|
-
// The URL constructor will preserve the absolute URL
|
|
348
|
-
expect(response.url).toBe("https://other-domain.com/page");
|
|
349
|
-
expect(revalidatePath).toHaveBeenCalledWith(
|
|
350
|
-
"https://other-domain.com/page",
|
|
351
|
-
);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it("should handle revalidation failure gracefully", async () => {
|
|
355
|
-
const mockRequest = new NextRequest(
|
|
356
|
-
"https://example.com/api/auth/logout?redirect=/dashboard",
|
|
357
|
-
);
|
|
358
|
-
|
|
359
|
-
vi.mocked(revalidatePath).mockImplementationOnce(() => {
|
|
360
|
-
throw new Error("Revalidation failed");
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
const routeHandler = handler();
|
|
364
|
-
const response = await routeHandler(mockRequest);
|
|
365
|
-
expect(response.url).toBe("https://example.com/dashboard");
|
|
366
|
-
expect(mockLogger.warn).toHaveBeenCalled();
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import type { AuthConfigWithDefaults } from "@/nextjs/config.js";
|
|
3
|
-
import { resolveCallbackUrl } from "@/nextjs/utils.js";
|
|
4
|
-
|
|
5
|
-
describe("Nextjs utils", () => {
|
|
6
|
-
describe("resolveCallbackUrl", () => {
|
|
7
|
-
it("should resolve the callbackUrl by combining the relative callbackUrl from config with baseUrl", () => {
|
|
8
|
-
const callbackUrl = resolveCallbackUrl(
|
|
9
|
-
{
|
|
10
|
-
callbackUrl: "/callback",
|
|
11
|
-
} as unknown as AuthConfigWithDefaults,
|
|
12
|
-
"https://example.com",
|
|
13
|
-
);
|
|
14
|
-
expect(callbackUrl).toBe("https://example.com/callback");
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Auth Client Public API Snapshot > should match the previous API snapshot 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"CivicAuthIframeContainer": [Function],
|
|
6
|
-
"CivicAuthProvider": [Function],
|
|
7
|
-
"SignInButton": [Function],
|
|
8
|
-
"SignOutButton": [Function],
|
|
9
|
-
"UserButton": [Function],
|
|
10
|
-
"useAuth": [Function],
|
|
11
|
-
"useConfig": [Function],
|
|
12
|
-
"useIframe": [Function],
|
|
13
|
-
"useSession": [Function],
|
|
14
|
-
"useToken": [Function],
|
|
15
|
-
"useUser": [Function],
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as authClient from "../../../src/reactjs/index.js";
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
// This test checks if the current state of the authClient matches the previously saved snapshot.
|
|
6
|
-
// If the API updates, you will need to update the snapshot by running the test:update script, i.e. `pnpm test:update`
|
|
7
|
-
describe("Auth Client Public API Snapshot", () => {
|
|
8
|
-
it("should match the previous API snapshot", () => {
|
|
9
|
-
expect(authClient).toMatchSnapshot();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
-
import { CivicAuthProvider } from "@/shared/providers/CivicAuthProvider.js";
|
|
5
|
-
import { SignInButton } from "@/reactjs/components/SignInButton.js";
|
|
6
|
-
import * as civicHook from "@/reactjs/hooks/useUser.js";
|
|
7
|
-
|
|
8
|
-
describe("SignInButton Component", () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
vi.clearAllMocks();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should render a SignInButton component", () => {
|
|
14
|
-
render(
|
|
15
|
-
<CivicAuthProvider
|
|
16
|
-
clientId="test-client-id"
|
|
17
|
-
redirectUrl="https://example.com"
|
|
18
|
-
>
|
|
19
|
-
<SignInButton />
|
|
20
|
-
</CivicAuthProvider>,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
expect(screen.getByText("Sign In")).toBeDefined();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should call signIn when the button is clicked", () => {
|
|
27
|
-
const mockSignIn = vi.fn();
|
|
28
|
-
|
|
29
|
-
vi.spyOn(civicHook, "useUser").mockReturnValue({
|
|
30
|
-
signIn: mockSignIn,
|
|
31
|
-
signOut: async () => {},
|
|
32
|
-
error: null,
|
|
33
|
-
isLoading: false,
|
|
34
|
-
user: null,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
render(
|
|
38
|
-
<CivicAuthProvider
|
|
39
|
-
clientId="test-client-id"
|
|
40
|
-
redirectUrl="https://example.com"
|
|
41
|
-
>
|
|
42
|
-
<SignInButton />
|
|
43
|
-
</CivicAuthProvider>,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
fireEvent.click(screen.getByText("Sign In"));
|
|
47
|
-
|
|
48
|
-
expect(mockSignIn).toHaveBeenCalled();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { fireEvent, render, screen } from "@testing-library/react";
|
|
3
|
-
import { CivicAuthProvider, SignOutButton } from "@/reactjs/index.js";
|
|
4
|
-
import * as userHook from "@/reactjs/hooks/useUser.js";
|
|
5
|
-
import React from "react";
|
|
6
|
-
|
|
7
|
-
describe("SignOutButton Component", () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
vi.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should render a SignOutButton component", () => {
|
|
13
|
-
render(
|
|
14
|
-
<CivicAuthProvider
|
|
15
|
-
clientId="test-client-id"
|
|
16
|
-
redirectUrl="https://example.com"
|
|
17
|
-
>
|
|
18
|
-
<SignOutButton />
|
|
19
|
-
</CivicAuthProvider>,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
expect(screen.getByText("Sign Out")).toBeDefined();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should call signIn when the button is clicked", () => {
|
|
26
|
-
const mockSignOut = vi.fn();
|
|
27
|
-
|
|
28
|
-
vi.spyOn(userHook, "useUser").mockReturnValue({
|
|
29
|
-
signOut: mockSignOut,
|
|
30
|
-
signIn: async () => {},
|
|
31
|
-
error: null,
|
|
32
|
-
isLoading: false,
|
|
33
|
-
user: null,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
render(
|
|
37
|
-
<CivicAuthProvider
|
|
38
|
-
clientId="test-client-id"
|
|
39
|
-
redirectUrl="https://example.com"
|
|
40
|
-
>
|
|
41
|
-
<SignOutButton />
|
|
42
|
-
</CivicAuthProvider>,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
fireEvent.click(screen.getByText("Sign Out"));
|
|
46
|
-
|
|
47
|
-
expect(mockSignOut).toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
resolveOAuthAccessCode,
|
|
4
|
-
isLoggedIn,
|
|
5
|
-
buildLoginUrl,
|
|
6
|
-
} from "@/server/login.js";
|
|
7
|
-
import { ServerAuthenticationResolver } from "@/server/ServerAuthenticationResolver.js";
|
|
8
|
-
import { GenericAuthenticationInitiator } from "@/services/AuthenticationService.js";
|
|
9
|
-
import { GenericPublicClientPKCEProducer } from "@/services/PKCE.js";
|
|
10
|
-
import { DEFAULT_AUTH_SERVER, DEFAULT_SCOPES } from "@/constants.js";
|
|
11
|
-
import type { AuthStorage, OIDCTokenResponseBody } from "@/types.js";
|
|
12
|
-
import type { AuthConfig } from "@/server/config.ts";
|
|
13
|
-
import type { PKCEProducer } from "@/services/types.ts";
|
|
14
|
-
|
|
15
|
-
vi.mock("@/server/ServerAuthenticationResolver");
|
|
16
|
-
vi.mock("@/services/AuthenticationService");
|
|
17
|
-
vi.mock("@/services/PKCE.js");
|
|
18
|
-
|
|
19
|
-
class StubPKCEProducer implements PKCEProducer {
|
|
20
|
-
constructor() {}
|
|
21
|
-
|
|
22
|
-
async getCodeChallenge(): Promise<string> {
|
|
23
|
-
return "dummyCodeChallenge";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async getCodeVerifier(): Promise<string> {
|
|
27
|
-
return "dummyCodeVerifier";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe("Login Utilities", () => {
|
|
32
|
-
const mockAuthConfig: AuthConfig = {
|
|
33
|
-
clientId: "mockClientId",
|
|
34
|
-
oauthServer: "http://mockOauthServer",
|
|
35
|
-
redirectUrl: "http://localhost/redirect",
|
|
36
|
-
};
|
|
37
|
-
const mockTokens: OIDCTokenResponseBody = {
|
|
38
|
-
id_token: "mockIdToken",
|
|
39
|
-
access_token: "mockAccessToken",
|
|
40
|
-
refresh_token: "mockRefreshToken",
|
|
41
|
-
};
|
|
42
|
-
const mockStorage = {
|
|
43
|
-
get: vi.fn(),
|
|
44
|
-
set: vi.fn(),
|
|
45
|
-
} as unknown as AuthStorage;
|
|
46
|
-
|
|
47
|
-
describe("resolveOAuthAccessCode", () => {
|
|
48
|
-
it("should resolve the OAuth access code and return tokens", async () => {
|
|
49
|
-
vi.mocked(ServerAuthenticationResolver.build).mockResolvedValue({
|
|
50
|
-
tokenExchange: vi.fn().mockResolvedValue(mockTokens),
|
|
51
|
-
} as unknown as ServerAuthenticationResolver);
|
|
52
|
-
|
|
53
|
-
const result = await resolveOAuthAccessCode(
|
|
54
|
-
"mockCode",
|
|
55
|
-
"mockState",
|
|
56
|
-
mockStorage,
|
|
57
|
-
mockAuthConfig,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
expect(ServerAuthenticationResolver.build).toHaveBeenCalledWith(
|
|
61
|
-
{
|
|
62
|
-
...mockAuthConfig,
|
|
63
|
-
oauthServer: mockAuthConfig.oauthServer ?? DEFAULT_AUTH_SERVER,
|
|
64
|
-
},
|
|
65
|
-
mockStorage,
|
|
66
|
-
undefined,
|
|
67
|
-
);
|
|
68
|
-
expect(result).toEqual(mockTokens);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("isLoggedIn", () => {
|
|
73
|
-
it("should return true if id_token is in storage", async () => {
|
|
74
|
-
vi.mocked(mockStorage.get).mockResolvedValue("mockIdToken");
|
|
75
|
-
|
|
76
|
-
const result = await isLoggedIn(mockStorage);
|
|
77
|
-
|
|
78
|
-
expect(result).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should return false if id_token is not in storage", async () => {
|
|
82
|
-
vi.mocked(mockStorage.get).mockResolvedValue(null);
|
|
83
|
-
|
|
84
|
-
const result = await isLoggedIn(mockStorage);
|
|
85
|
-
|
|
86
|
-
expect(result).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe("buildLoginUrl", () => {
|
|
91
|
-
it("should generate a login URL with provided config", async () => {
|
|
92
|
-
const state = "mockState";
|
|
93
|
-
const scopes = ["openid", "profile"];
|
|
94
|
-
const pkceProducer = new StubPKCEProducer();
|
|
95
|
-
|
|
96
|
-
const authInitiator = new GenericAuthenticationInitiator({
|
|
97
|
-
...mockAuthConfig,
|
|
98
|
-
state,
|
|
99
|
-
scopes,
|
|
100
|
-
oauthServer: mockAuthConfig.oauthServer ?? DEFAULT_AUTH_SERVER,
|
|
101
|
-
pkceConsumer: pkceProducer,
|
|
102
|
-
});
|
|
103
|
-
vi.mocked(GenericAuthenticationInitiator).mockReturnValue(authInitiator);
|
|
104
|
-
vi.mocked(authInitiator.signIn).mockResolvedValue(
|
|
105
|
-
new URL("http://mockLoginUrl"),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const result = await buildLoginUrl(
|
|
109
|
-
{
|
|
110
|
-
...mockAuthConfig,
|
|
111
|
-
state,
|
|
112
|
-
scopes,
|
|
113
|
-
},
|
|
114
|
-
mockStorage,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
expect(result.toString()).toBe("http://mockloginurl/");
|
|
118
|
-
expect(GenericAuthenticationInitiator).toHaveBeenCalledWith({
|
|
119
|
-
...mockAuthConfig,
|
|
120
|
-
state,
|
|
121
|
-
scopes,
|
|
122
|
-
oauthServer: mockAuthConfig.oauthServer ?? DEFAULT_AUTH_SERVER,
|
|
123
|
-
pkceConsumer: pkceProducer,
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("should generate a login URL with default state and scopes", async () => {
|
|
128
|
-
const authInitiator = new GenericAuthenticationInitiator({
|
|
129
|
-
...mockAuthConfig,
|
|
130
|
-
state: expect.any(String), // state is random if not provided
|
|
131
|
-
scopes: DEFAULT_SCOPES,
|
|
132
|
-
oauthServer: mockAuthConfig.oauthServer ?? DEFAULT_AUTH_SERVER,
|
|
133
|
-
pkceConsumer: expect.any(GenericPublicClientPKCEProducer),
|
|
134
|
-
});
|
|
135
|
-
vi.mocked(GenericAuthenticationInitiator).mockReturnValue(authInitiator);
|
|
136
|
-
vi.mocked(authInitiator.signIn).mockResolvedValue(
|
|
137
|
-
new URL("http://mockLoginUrl"),
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const result = await buildLoginUrl(mockAuthConfig, mockStorage);
|
|
141
|
-
|
|
142
|
-
expect(result.toString()).toBe("http://mockloginurl/");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("should include nonce in the login URL if provided in config", async () => {
|
|
146
|
-
const state = "mockState";
|
|
147
|
-
const scopes = ["openid", "profile"];
|
|
148
|
-
const nonce = "mockNonce";
|
|
149
|
-
const pkceProducer = new GenericPublicClientPKCEProducer(mockStorage);
|
|
150
|
-
|
|
151
|
-
const authInitiator = new GenericAuthenticationInitiator({
|
|
152
|
-
...mockAuthConfig,
|
|
153
|
-
state,
|
|
154
|
-
scopes,
|
|
155
|
-
oauthServer: mockAuthConfig.oauthServer ?? DEFAULT_AUTH_SERVER,
|
|
156
|
-
pkceConsumer: pkceProducer,
|
|
157
|
-
nonce,
|
|
158
|
-
});
|
|
159
|
-
vi.mocked(GenericAuthenticationInitiator).mockReturnValue(authInitiator);
|
|
160
|
-
vi.mocked(authInitiator.signIn).mockResolvedValue(
|
|
161
|
-
new URL(`http://mockLoginUrl?nonce=${nonce}`),
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
await buildLoginUrl(
|
|
165
|
-
{
|
|
166
|
-
...mockAuthConfig,
|
|
167
|
-
state,
|
|
168
|
-
scopes,
|
|
169
|
-
nonce,
|
|
170
|
-
},
|
|
171
|
-
mockStorage,
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
expect(GenericAuthenticationInitiator).toHaveBeenCalledWith(
|
|
175
|
-
expect.objectContaining({
|
|
176
|
-
nonce,
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|