@civic/auth 0.1.3 → 0.1.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +13 -10
- 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/GetUser.d.ts.map +1 -1
- package/dist/cjs/nextjs/GetUser.js +2 -13
- package/dist/cjs/nextjs/GetUser.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 +4 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.js +43 -15
- 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/nextjs/routeHandler.js +2 -2
- package/dist/cjs/nextjs/routeHandler.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 +18 -8
- 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/session.d.ts +1 -1
- package/dist/cjs/shared/lib/session.d.ts.map +1 -1
- package/dist/cjs/shared/lib/session.js +12 -1
- package/dist/cjs/shared/lib/session.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 +28 -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 +6 -4
- package/dist/cjs/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/UserProvider.js +49 -26
- package/dist/cjs/shared/providers/UserProvider.js.map +1 -1
- package/dist/cjs/types.d.ts +5 -5
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +4 -0
- 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/GetUser.d.ts.map +1 -1
- package/dist/esm/nextjs/GetUser.js +2 -13
- package/dist/esm/nextjs/GetUser.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 +4 -1
- package/dist/esm/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/esm/nextjs/hooks/useUserCookie.js +45 -17
- 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/nextjs/routeHandler.js +2 -2
- package/dist/esm/nextjs/routeHandler.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/CivicAuthIframe.js +1 -1
- package/dist/esm/shared/components/CivicAuthIframe.js.map +1 -1
- 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/session.d.ts +1 -1
- package/dist/esm/shared/lib/session.d.ts.map +1 -1
- package/dist/esm/shared/lib/session.js +12 -1
- package/dist/esm/shared/lib/session.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 +11 -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 +6 -4
- package/dist/esm/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/UserProvider.js +33 -20
- package/dist/esm/shared/providers/UserProvider.js.map +1 -1
- package/dist/esm/types.d.ts +5 -5
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +3 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/src/browser/storage.d.ts +3 -0
- package/dist/src/browser/storage.d.ts.map +1 -1
- package/dist/src/browser/storage.js +8 -0
- package/dist/src/browser/storage.js.map +1 -1
- package/dist/src/lib/cookies.d.ts +2 -2
- package/dist/src/lib/cookies.d.ts.map +1 -1
- package/dist/src/lib/cookies.js +7 -5
- package/dist/src/lib/cookies.js.map +1 -1
- package/dist/src/lib/postMessage.js +1 -1
- package/dist/src/lib/postMessage.js.map +1 -1
- package/dist/src/lib/windowUtil.d.ts.map +1 -1
- package/dist/src/lib/windowUtil.js +1 -0
- package/dist/src/lib/windowUtil.js.map +1 -1
- package/dist/src/nextjs/GetUser.d.ts.map +1 -1
- package/dist/src/nextjs/GetUser.js +2 -13
- package/dist/src/nextjs/GetUser.js.map +1 -1
- package/dist/src/nextjs/config.d.ts.map +1 -1
- package/dist/src/nextjs/config.js +12 -0
- package/dist/src/nextjs/config.js.map +1 -1
- package/dist/src/nextjs/hooks/index.d.ts +1 -1
- package/dist/src/nextjs/hooks/index.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/index.js +1 -1
- package/dist/src/nextjs/hooks/index.js.map +1 -1
- package/dist/src/nextjs/hooks/useRefresh.d.ts +4 -0
- package/dist/src/nextjs/hooks/useRefresh.d.ts.map +1 -0
- package/dist/src/nextjs/hooks/useRefresh.js +38 -0
- package/dist/src/nextjs/hooks/useRefresh.js.map +1 -0
- package/dist/src/nextjs/hooks/useUserCookie.d.ts +4 -1
- package/dist/src/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/useUserCookie.js +45 -17
- package/dist/src/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts +5 -1
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
- package/dist/src/nextjs/providers/NextAuthProvider.js +59 -30
- package/dist/src/nextjs/providers/NextAuthProvider.js.map +1 -1
- package/dist/src/nextjs/routeHandler.js +2 -2
- package/dist/src/nextjs/routeHandler.js.map +1 -1
- package/dist/src/reactjs/components/UserButton.js +3 -3
- package/dist/src/reactjs/components/UserButton.js.map +1 -1
- package/dist/src/reactjs/hooks/index.d.ts +0 -1
- package/dist/src/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/src/reactjs/hooks/index.js +0 -1
- package/dist/src/reactjs/hooks/index.js.map +1 -1
- package/dist/src/reactjs/hooks/useRefresh.d.ts +4 -0
- package/dist/src/reactjs/hooks/useRefresh.d.ts.map +1 -0
- package/dist/src/reactjs/hooks/useRefresh.js +28 -0
- package/dist/src/reactjs/hooks/useRefresh.js.map +1 -0
- package/dist/src/services/AuthenticationService.d.ts +4 -1
- package/dist/src/services/AuthenticationService.d.ts.map +1 -1
- package/dist/src/services/AuthenticationService.js +39 -8
- package/dist/src/services/AuthenticationService.js.map +1 -1
- package/dist/src/shared/components/BlockDisplay.d.ts +7 -0
- package/dist/src/shared/components/BlockDisplay.d.ts.map +1 -0
- package/dist/src/shared/components/BlockDisplay.js +25 -0
- package/dist/src/shared/components/BlockDisplay.js.map +1 -0
- package/dist/src/shared/components/CivicAuthIframe.js +1 -1
- package/dist/src/shared/components/CivicAuthIframe.js.map +1 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.js +23 -14
- package/dist/src/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/src/shared/components/IFrameAndLoading.d.ts +7 -0
- package/dist/src/shared/components/IFrameAndLoading.d.ts.map +1 -0
- package/dist/src/shared/components/IFrameAndLoading.js +22 -0
- package/dist/src/shared/components/IFrameAndLoading.js.map +1 -0
- package/dist/src/shared/hooks/index.d.ts +5 -1
- package/dist/src/shared/hooks/index.d.ts.map +1 -1
- package/dist/src/shared/hooks/index.js +5 -1
- package/dist/src/shared/hooks/index.js.map +1 -1
- package/dist/src/shared/hooks/useCivicAuthConfig.d.ts +3 -0
- package/dist/src/shared/hooks/useCivicAuthConfig.d.ts.map +1 -0
- package/dist/src/shared/hooks/useCivicAuthConfig.js +10 -0
- package/dist/src/shared/hooks/useCivicAuthConfig.js.map +1 -0
- package/dist/src/shared/hooks/useClientTokenExchangeSession.d.ts +3 -0
- package/dist/src/shared/hooks/useClientTokenExchangeSession.d.ts.map +1 -0
- package/dist/src/shared/hooks/useClientTokenExchangeSession.js +13 -0
- package/dist/src/shared/hooks/useClientTokenExchangeSession.js.map +1 -0
- package/dist/src/shared/hooks/useCurrentUrl.d.ts +3 -0
- package/dist/src/shared/hooks/useCurrentUrl.d.ts.map +1 -0
- package/dist/src/shared/hooks/useCurrentUrl.js +24 -0
- package/dist/src/shared/hooks/useCurrentUrl.js.map +1 -0
- package/dist/src/shared/hooks/useIsInIframe.d.ts +3 -0
- package/dist/src/shared/hooks/useIsInIframe.d.ts.map +1 -0
- package/dist/src/shared/hooks/useIsInIframe.js +14 -0
- package/dist/src/shared/hooks/useIsInIframe.js.map +1 -0
- package/dist/src/shared/hooks/useOAuthEndpoints.d.ts +4 -0
- package/dist/src/shared/hooks/useOAuthEndpoints.d.ts.map +1 -0
- package/dist/src/shared/hooks/useOAuthEndpoints.js +14 -0
- package/dist/src/shared/hooks/useOAuthEndpoints.js.map +1 -0
- package/dist/src/shared/hooks/useRefresh.d.ts +4 -0
- package/dist/src/shared/hooks/useRefresh.d.ts.map +1 -0
- package/dist/src/shared/hooks/useRefresh.js +38 -0
- package/dist/src/shared/hooks/useRefresh.js.map +1 -0
- package/dist/src/shared/hooks/useSession.d.ts +1 -1
- package/dist/src/shared/hooks/useSession.d.ts.map +1 -1
- package/dist/src/shared/hooks/useSignIn.d.ts +14 -0
- package/dist/src/shared/hooks/useSignIn.d.ts.map +1 -0
- package/dist/src/shared/hooks/useSignIn.js +71 -0
- package/dist/src/shared/hooks/useSignIn.js.map +1 -0
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts +4 -0
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js +30 -0
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/src/shared/lib/session.d.ts +1 -1
- package/dist/src/shared/lib/session.d.ts.map +1 -1
- package/dist/src/shared/lib/session.js +12 -1
- package/dist/src/shared/lib/session.js.map +1 -1
- package/dist/src/shared/lib/types.d.ts +14 -1
- package/dist/src/shared/lib/types.d.ts.map +1 -1
- package/dist/src/shared/lib/types.js +2 -0
- package/dist/src/shared/lib/types.js.map +1 -1
- package/dist/src/shared/lib/util.d.ts.map +1 -1
- package/dist/src/shared/lib/util.js +11 -2
- package/dist/src/shared/lib/util.js.map +1 -1
- package/dist/src/shared/providers/AuthProvider.d.ts +3 -2
- package/dist/src/shared/providers/AuthProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/AuthProvider.js +37 -238
- package/dist/src/shared/providers/AuthProvider.js.map +1 -1
- package/dist/src/shared/providers/CivicAuthConfigContext.d.ts +16 -0
- package/dist/src/shared/providers/CivicAuthConfigContext.d.ts.map +1 -0
- package/dist/src/shared/providers/CivicAuthConfigContext.js +43 -0
- package/dist/src/shared/providers/CivicAuthConfigContext.js.map +1 -0
- package/dist/src/shared/providers/CivicAuthProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/CivicAuthProvider.js +23 -6
- package/dist/src/shared/providers/CivicAuthProvider.js.map +1 -1
- package/dist/src/shared/providers/ClientTokenExchangeSessionProvider.d.ts +17 -0
- package/dist/src/shared/providers/ClientTokenExchangeSessionProvider.d.ts.map +1 -0
- package/dist/src/shared/providers/ClientTokenExchangeSessionProvider.js +146 -0
- package/dist/src/shared/providers/ClientTokenExchangeSessionProvider.js.map +1 -0
- package/dist/src/shared/providers/IframeProvider.d.ts +7 -4
- package/dist/src/shared/providers/IframeProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/IframeProvider.js +21 -3
- package/dist/src/shared/providers/IframeProvider.js.map +1 -1
- package/dist/src/shared/providers/SessionProvider.d.ts +10 -4
- package/dist/src/shared/providers/SessionProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/SessionProvider.js +15 -5
- package/dist/src/shared/providers/SessionProvider.js.map +1 -1
- package/dist/src/shared/providers/TokenProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/TokenProvider.js +13 -24
- package/dist/src/shared/providers/TokenProvider.js.map +1 -1
- package/dist/src/shared/providers/UserProvider.d.ts +6 -4
- package/dist/src/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/src/shared/providers/UserProvider.js +33 -20
- package/dist/src/shared/providers/UserProvider.js.map +1 -1
- package/dist/src/types.d.ts +5 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +3 -1
- package/dist/src/types.js.map +1 -1
- package/dist/test/integration/sdk.test.d.ts.map +1 -1
- package/dist/test/integration/sdk.test.js +39 -33
- package/dist/test/integration/sdk.test.js.map +1 -1
- package/dist/test/unit/nextjs/NextAuthProvider.test.js +8 -6
- package/dist/test/unit/nextjs/NextAuthProvider.test.js.map +1 -1
- package/dist/test/unit/nextjs/getUser.test.js +2 -16
- package/dist/test/unit/nextjs/getUser.test.js.map +1 -1
- package/dist/test/unit/server/refresh.test.d.ts.map +1 -0
- package/dist/test/unit/services/AuthenticationService.test.js +18 -1
- package/dist/test/unit/services/AuthenticationService.test.js.map +1 -1
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.js +12 -10
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.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/config.d.ts +0 -3
- 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.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/lib/jwt.d.ts +0 -3
- 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.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/windowUtil.d.ts +0 -4
- package/dist/src/nextjs/GetUser.d.ts +0 -6
- package/dist/src/nextjs/config.d.ts +0 -178
- package/dist/src/nextjs/cookies.d.ts +0 -30
- package/dist/src/nextjs/cookies.js +0 -112
- package/dist/src/nextjs/cookies.js.map +0 -1
- package/dist/src/nextjs/index.d.ts +0 -7
- 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.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.js +0 -107
- package/dist/src/nextjs/middleware.js.map +0 -1
- package/dist/src/nextjs/routeHandler.d.ts +0 -18
- package/dist/src/nextjs/utils.d.ts +0 -3
- 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.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.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/index.d.ts +0 -6
- package/dist/src/reactjs/components/index.js +0 -6
- package/dist/src/reactjs/components/index.js.map +0 -1
- package/dist/src/reactjs/hooks/useAuth.d.ts +0 -3
- 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.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.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.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.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.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.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.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.js +0 -13
- package/dist/src/server/refresh.js.map +0 -1
- package/dist/src/services/PKCE.d.ts +0 -20
- 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.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/CivicAuthIframeContainer.d.ts +0 -9
- 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/useAuth.d.ts +0 -3
- package/dist/src/shared/hooks/useAuth.js +0 -12
- package/dist/src/shared/hooks/useAuth.js.map +0 -1
- package/dist/src/shared/hooks/useIframe.d.ts +0 -3
- 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.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.js +0 -12
- package/dist/src/shared/hooks/useToken.js.map +0 -1
- package/dist/src/shared/lib/UserSession.d.ts +0 -12
- package/dist/src/shared/lib/UserSession.js +0 -20
- package/dist/src/shared/lib/UserSession.js.map +0 -1
- package/dist/src/shared/lib/storage.d.ts +0 -25
- package/dist/src/shared/lib/storage.js +0 -17
- package/dist/src/shared/lib/storage.js.map +0 -1
- package/dist/src/shared/lib/util.d.ts +0 -33
- package/dist/src/shared/providers/AuthContext.d.ts +0 -10
- package/dist/src/shared/providers/AuthContext.js +0 -3
- package/dist/src/shared/providers/AuthContext.js.map +0 -1
- package/dist/src/shared/providers/CivicAuthProvider.d.ts +0 -6
- package/dist/src/shared/providers/TokenProvider.d.ts +0 -18
- 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/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.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/config.test.d.ts +0 -2
- 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/middleware.test.d.ts +0 -2
- 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.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.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.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.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.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.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/ServerAuthenticationResolver.test.d.ts +0 -2
- 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.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.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/storage.test.d.ts +0 -2
- 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,297 +0,0 @@
|
|
|
1
|
-
import type { NextRequest } from "next/server.js";
|
|
2
|
-
import { NextResponse } from "next/server.js";
|
|
3
|
-
import { revalidatePath } from "next/cache.js";
|
|
4
|
-
import type { AuthConfig } from "@/nextjs/config.js";
|
|
5
|
-
import { resolveAuthConfig } from "@/nextjs/config.js";
|
|
6
|
-
import { loggers } from "@/lib/logger.js";
|
|
7
|
-
import {
|
|
8
|
-
clearAuthCookies,
|
|
9
|
-
NextjsClientStorage,
|
|
10
|
-
NextjsCookieStorage,
|
|
11
|
-
} from "@/nextjs/cookies.js";
|
|
12
|
-
import { GenericPublicClientPKCEProducer } from "@/services/PKCE.js";
|
|
13
|
-
import { resolveOAuthAccessCode } from "@/server/login.js";
|
|
14
|
-
import { getUser } from "@/shared/lib/session.js";
|
|
15
|
-
import { resolveCallbackUrl } from "@/nextjs/utils.js";
|
|
16
|
-
import { GenericUserSession } from "@/shared/lib/UserSession.js";
|
|
17
|
-
import {
|
|
18
|
-
TOKEN_EXCHANGE_SUCCESS_TEXT,
|
|
19
|
-
TOKEN_EXCHANGE_TRIGGER_TEXT,
|
|
20
|
-
} from "@/constants.js";
|
|
21
|
-
import { serverTokenExchangeFromState } from "@/lib/oauth.js";
|
|
22
|
-
import { CodeVerifier } from "@/shared/lib/types.js";
|
|
23
|
-
|
|
24
|
-
const logger = loggers.nextjs.handlers.auth;
|
|
25
|
-
|
|
26
|
-
class AuthError extends Error {
|
|
27
|
-
constructor(
|
|
28
|
-
message: string,
|
|
29
|
-
public readonly status: number = 401,
|
|
30
|
-
) {
|
|
31
|
-
super(message);
|
|
32
|
-
this.name = "AuthError";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* create a code verifier and challenge for PKCE
|
|
38
|
-
* saving the verifier in a cookie for later use
|
|
39
|
-
* @returns {Promise<NextResponse>}
|
|
40
|
-
*/
|
|
41
|
-
async function handleChallenge(
|
|
42
|
-
request: NextRequest,
|
|
43
|
-
config: AuthConfig,
|
|
44
|
-
): Promise<NextResponse> {
|
|
45
|
-
const cookieStorage = new NextjsCookieStorage(config.cookies?.tokens ?? {});
|
|
46
|
-
const pkceProducer = new GenericPublicClientPKCEProducer(cookieStorage);
|
|
47
|
-
|
|
48
|
-
const challenge = await pkceProducer.getCodeChallenge();
|
|
49
|
-
const appUrl = request.nextUrl.searchParams.get("appUrl");
|
|
50
|
-
if (appUrl) {
|
|
51
|
-
cookieStorage.set(CodeVerifier.APP_URL, appUrl);
|
|
52
|
-
}
|
|
53
|
-
return NextResponse.json({ status: "success", challenge });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function performTokenExchangeAndSetCookies(
|
|
57
|
-
request: NextRequest,
|
|
58
|
-
config: AuthConfig,
|
|
59
|
-
code: string,
|
|
60
|
-
state: string,
|
|
61
|
-
appUrl: string,
|
|
62
|
-
) {
|
|
63
|
-
const resolvedConfigs = resolveAuthConfig(config);
|
|
64
|
-
const cookieStorage = new NextjsCookieStorage(resolvedConfigs.cookies.tokens);
|
|
65
|
-
|
|
66
|
-
const callbackUrl = resolveCallbackUrl(resolvedConfigs, appUrl);
|
|
67
|
-
try {
|
|
68
|
-
await resolveOAuthAccessCode(code, state, cookieStorage, {
|
|
69
|
-
...resolvedConfigs,
|
|
70
|
-
redirectUrl: callbackUrl,
|
|
71
|
-
});
|
|
72
|
-
} catch (error) {
|
|
73
|
-
logger.error("Token exchange failed:", error);
|
|
74
|
-
throw new AuthError("Failed to authenticate user", 401);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const user = await getUser(cookieStorage);
|
|
78
|
-
if (!user) {
|
|
79
|
-
throw new AuthError("Failed to get user info", 401);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const clientStorage = new NextjsClientStorage();
|
|
83
|
-
const userSession = new GenericUserSession(clientStorage);
|
|
84
|
-
userSession.set(user);
|
|
85
|
-
}
|
|
86
|
-
async function handleCallback(
|
|
87
|
-
request: NextRequest,
|
|
88
|
-
config: AuthConfig,
|
|
89
|
-
): Promise<NextResponse> {
|
|
90
|
-
const resolvedConfigs = resolveAuthConfig(config);
|
|
91
|
-
console.log("handleCallback", { request, resolvedConfigs });
|
|
92
|
-
const code = request.nextUrl.searchParams.get("code");
|
|
93
|
-
const state = request.nextUrl.searchParams.get("state") || "";
|
|
94
|
-
if (!code || !state) throw new AuthError("Bad parameters", 400);
|
|
95
|
-
|
|
96
|
-
// appUrl is passed from the client to the server in the query string
|
|
97
|
-
// this is necessary because the server does not have access to the client's window.location.origin
|
|
98
|
-
// and can not accurately determine the appUrl (specially if the app is behind a reverse proxy)
|
|
99
|
-
const appUrl =
|
|
100
|
-
request.cookies.get(CodeVerifier.APP_URL)?.value ||
|
|
101
|
-
request.nextUrl.searchParams.get("appUrl");
|
|
102
|
-
|
|
103
|
-
// If we have a code_verifier cookie and the appUrl, we can do a token exchange.
|
|
104
|
-
// Otherwise, just render an empty page.
|
|
105
|
-
// The initial redirect back from the auth server does not send cookies, because the redirect is from a 3rd-party domain.
|
|
106
|
-
// The client will make an additional call to this route with cookies included, at which point we do the token exchange.
|
|
107
|
-
console.log("handleCallback", {
|
|
108
|
-
code,
|
|
109
|
-
state,
|
|
110
|
-
appUrl,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const codeVerifier = request.cookies.get(CodeVerifier.COOKIE_NAME);
|
|
114
|
-
|
|
115
|
-
if (!codeVerifier || !appUrl) {
|
|
116
|
-
console.log("handleCallback no code_verifier found", {
|
|
117
|
-
state,
|
|
118
|
-
serverTokenExchange: serverTokenExchangeFromState(`${state}`),
|
|
119
|
-
});
|
|
120
|
-
let response = new NextResponse(
|
|
121
|
-
`<html><body><span style="display:none">${TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`,
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// in server-side token exchange mode we need to launch a page that will trigger the token exchange
|
|
125
|
-
// from the same domain, allowing it access to the code_verifier cookie
|
|
126
|
-
// we only need to do this in redirect mode, as the iframe already triggers a client-side token exchange
|
|
127
|
-
// if no code-verifier cookie is found
|
|
128
|
-
if (state && serverTokenExchangeFromState(state)) {
|
|
129
|
-
console.log(
|
|
130
|
-
"handleCallback serverTokenExchangeFromState, launching redirect page...",
|
|
131
|
-
{
|
|
132
|
-
requestUrl: request.url,
|
|
133
|
-
configCallbackUrl: resolvedConfigs.callbackUrl,
|
|
134
|
-
},
|
|
135
|
-
);
|
|
136
|
-
// we need to replace the URL with resolved config in case the server is hosted
|
|
137
|
-
// behind a reverse proxy or load balancer
|
|
138
|
-
const requestUrl = new URL(request.url);
|
|
139
|
-
const fetchUrl = `${resolvedConfigs.callbackUrl}?${requestUrl.searchParams.toString()}&sameDomainServerTokenExchange=true`;
|
|
140
|
-
response = new NextResponse(
|
|
141
|
-
`<html>
|
|
142
|
-
<body>
|
|
143
|
-
<span style="display:none">
|
|
144
|
-
<script>
|
|
145
|
-
window.onload = function () {
|
|
146
|
-
const appUrl = globalThis.window?.location?.origin;
|
|
147
|
-
fetch('${fetchUrl}&appUrl=' + appUrl).then((response) => {
|
|
148
|
-
response.json().then((jsonResponse) => {
|
|
149
|
-
if (jsonResponse.redirectUrl) {
|
|
150
|
-
window.location.href = jsonResponse.redirectUrl;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
</script>
|
|
156
|
-
</span>
|
|
157
|
-
</body>
|
|
158
|
-
</html>
|
|
159
|
-
`,
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
response.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
163
|
-
console.log(
|
|
164
|
-
`handleCallback no code_verifier found, returning ${TOKEN_EXCHANGE_TRIGGER_TEXT}`,
|
|
165
|
-
);
|
|
166
|
-
return response;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
await performTokenExchangeAndSetCookies(
|
|
170
|
-
request,
|
|
171
|
-
resolvedConfigs,
|
|
172
|
-
code,
|
|
173
|
-
state,
|
|
174
|
-
appUrl,
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
if (request.url.includes("sameDomainServerTokenExchange=true")) {
|
|
178
|
-
console.log(
|
|
179
|
-
"handleCallback sameDomainServerTokenExchange = true, returnining redirectUrl",
|
|
180
|
-
appUrl,
|
|
181
|
-
);
|
|
182
|
-
return NextResponse.json({
|
|
183
|
-
status: "success",
|
|
184
|
-
redirectUrl: appUrl,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// this is the case where a 'normal' redirect is happening
|
|
189
|
-
if (serverTokenExchangeFromState(state)) {
|
|
190
|
-
console.log(
|
|
191
|
-
"handleCallback serverTokenExchangeFromState, redirect to appUrl",
|
|
192
|
-
appUrl,
|
|
193
|
-
);
|
|
194
|
-
if (!appUrl) {
|
|
195
|
-
throw new Error("appUrl undefined. Cannot redirect.");
|
|
196
|
-
}
|
|
197
|
-
return NextResponse.redirect(`${appUrl}`);
|
|
198
|
-
}
|
|
199
|
-
// return an empty HTML response so the iframe doesn't show any response
|
|
200
|
-
// in the short moment between the redirect and the parent window
|
|
201
|
-
// acknowledging the redirect and closing the iframe
|
|
202
|
-
const response = new NextResponse(
|
|
203
|
-
`<html><span style="display:none">${TOKEN_EXCHANGE_SUCCESS_TEXT}</span></html>`,
|
|
204
|
-
);
|
|
205
|
-
response.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
206
|
-
return response;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* If redirectPath is an absolute path, return it as-is.
|
|
211
|
-
* Otherwise for relative paths, append it to the current domain.
|
|
212
|
-
* @param redirectPath
|
|
213
|
-
* @returns
|
|
214
|
-
*/
|
|
215
|
-
const getAbsoluteRedirectPath = (
|
|
216
|
-
redirectPath: string,
|
|
217
|
-
currentBasePath: string,
|
|
218
|
-
) => new URL(redirectPath, currentBasePath).href;
|
|
219
|
-
|
|
220
|
-
export async function handleLogout(
|
|
221
|
-
request: NextRequest,
|
|
222
|
-
config: AuthConfig,
|
|
223
|
-
): Promise<NextResponse> {
|
|
224
|
-
const resolvedConfigs = resolveAuthConfig(config);
|
|
225
|
-
const defaultRedirectPath = resolvedConfigs.loginUrl ?? "/";
|
|
226
|
-
const redirectTarget =
|
|
227
|
-
new URL(request.url).searchParams.get("redirect") || defaultRedirectPath;
|
|
228
|
-
|
|
229
|
-
const isAbsoluteRedirect = /^(https?:\/\/|www\.).+/i.test(redirectTarget);
|
|
230
|
-
|
|
231
|
-
const appUrl = request.nextUrl.searchParams.get("appUrl");
|
|
232
|
-
|
|
233
|
-
const finalRedirectUrl = isAbsoluteRedirect
|
|
234
|
-
? redirectTarget
|
|
235
|
-
: getAbsoluteRedirectPath(
|
|
236
|
-
redirectTarget,
|
|
237
|
-
new URL(appUrl ?? request.url).origin,
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
const response = NextResponse.redirect(finalRedirectUrl);
|
|
241
|
-
|
|
242
|
-
await clearAuthCookies(config);
|
|
243
|
-
|
|
244
|
-
try {
|
|
245
|
-
revalidatePath(isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);
|
|
246
|
-
} catch (error) {
|
|
247
|
-
logger.warn("Failed to revalidate path after logout:", error);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return response;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Creates an authentication handler for Next.js API routes
|
|
255
|
-
*
|
|
256
|
-
* Usage:
|
|
257
|
-
* ```ts
|
|
258
|
-
* // app/api/auth/[...civicauth]/route.ts
|
|
259
|
-
* import { handler } from '@civic/auth/nextjs'
|
|
260
|
-
* export const GET = handler({
|
|
261
|
-
* // optional config overrides
|
|
262
|
-
* })
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
export const handler =
|
|
266
|
-
(authConfig = {}) =>
|
|
267
|
-
async (request: NextRequest): Promise<NextResponse> => {
|
|
268
|
-
const config = resolveAuthConfig(authConfig);
|
|
269
|
-
|
|
270
|
-
try {
|
|
271
|
-
const pathname = request.nextUrl.pathname;
|
|
272
|
-
const pathSegments = pathname.split("/");
|
|
273
|
-
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
274
|
-
|
|
275
|
-
switch (lastSegment) {
|
|
276
|
-
case "challenge":
|
|
277
|
-
return await handleChallenge(request, config);
|
|
278
|
-
case "callback":
|
|
279
|
-
return await handleCallback(request, config);
|
|
280
|
-
case "logout":
|
|
281
|
-
return await handleLogout(request, config);
|
|
282
|
-
default:
|
|
283
|
-
throw new AuthError(`Invalid auth route: ${pathname}`, 404);
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
logger.error("Auth handler error:", error);
|
|
287
|
-
|
|
288
|
-
const status = error instanceof AuthError ? error.status : 500;
|
|
289
|
-
const message =
|
|
290
|
-
error instanceof Error ? error.message : "Authentication failed";
|
|
291
|
-
|
|
292
|
-
const response = NextResponse.json({ error: message }, { status });
|
|
293
|
-
|
|
294
|
-
clearAuthCookies(config);
|
|
295
|
-
return response;
|
|
296
|
-
}
|
|
297
|
-
};
|
package/src/nextjs/utils.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AuthConfigWithDefaults } from "@/nextjs/config.js";
|
|
2
|
-
|
|
3
|
-
export const resolveCallbackUrl = (
|
|
4
|
-
config: AuthConfigWithDefaults,
|
|
5
|
-
baseUrl?: string,
|
|
6
|
-
): string => {
|
|
7
|
-
const callbackUrl = new URL(config?.callbackUrl, baseUrl).toString();
|
|
8
|
-
return callbackUrl.toString();
|
|
9
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import type { DisplayMode } from "@/types.js";
|
|
4
|
-
import { useUser } from "@/reactjs/hooks/useUser.js";
|
|
5
|
-
|
|
6
|
-
const SignInButton = ({
|
|
7
|
-
displayMode,
|
|
8
|
-
className,
|
|
9
|
-
}: {
|
|
10
|
-
displayMode?: DisplayMode;
|
|
11
|
-
className?: string;
|
|
12
|
-
}) => {
|
|
13
|
-
const { signIn } = useUser();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<button
|
|
17
|
-
data-testid="sign-in-button"
|
|
18
|
-
style={{
|
|
19
|
-
borderRadius: "9999px",
|
|
20
|
-
border: "1px solid #6b7280",
|
|
21
|
-
padding: "0.75rem 1rem",
|
|
22
|
-
transition: "background-color 0.2s",
|
|
23
|
-
}}
|
|
24
|
-
className={className}
|
|
25
|
-
onClick={() => signIn(displayMode)}
|
|
26
|
-
>
|
|
27
|
-
Sign In
|
|
28
|
-
</button>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { SignInButton };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { useUser } from "@/reactjs/hooks/useUser.js";
|
|
4
|
-
|
|
5
|
-
const SignOutButton = ({ className }: { className?: string }) => {
|
|
6
|
-
const { signOut } = useUser();
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<button
|
|
10
|
-
style={{
|
|
11
|
-
borderRadius: "9999px",
|
|
12
|
-
border: "1px solid #6b7280",
|
|
13
|
-
padding: "0.75rem 1rem",
|
|
14
|
-
transition: "background-color 0.2s",
|
|
15
|
-
}}
|
|
16
|
-
className={className}
|
|
17
|
-
onClick={() => signOut()}
|
|
18
|
-
>
|
|
19
|
-
Sign Out
|
|
20
|
-
</button>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { SignOutButton };
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useUser } from "@/reactjs/hooks/index.js";
|
|
3
|
-
import type { DisplayMode } from "@/types.js";
|
|
4
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
const ChevronDown = () => (
|
|
7
|
-
<svg
|
|
8
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
-
width="24"
|
|
10
|
-
height="24"
|
|
11
|
-
viewBox="0 0 24 24"
|
|
12
|
-
fill="none"
|
|
13
|
-
stroke="currentColor"
|
|
14
|
-
strokeWidth="2"
|
|
15
|
-
strokeLinecap="round"
|
|
16
|
-
strokeLinejoin="round"
|
|
17
|
-
className="lucide lucide-chevron-down"
|
|
18
|
-
>
|
|
19
|
-
<path d="m6 9 6 6 6-6" />
|
|
20
|
-
</svg>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const ChevronUp = () => (
|
|
24
|
-
<svg
|
|
25
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
-
width="24"
|
|
27
|
-
height="24"
|
|
28
|
-
viewBox="0 0 24 24"
|
|
29
|
-
fill="none"
|
|
30
|
-
stroke="currentColor"
|
|
31
|
-
strokeWidth="2"
|
|
32
|
-
strokeLinecap="round"
|
|
33
|
-
strokeLinejoin="round"
|
|
34
|
-
className="lucide lucide-chevron-up"
|
|
35
|
-
>
|
|
36
|
-
<path d="m18 15-6-6-6 6" />
|
|
37
|
-
</svg>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const UserButton = ({
|
|
41
|
-
displayMode,
|
|
42
|
-
className,
|
|
43
|
-
}: {
|
|
44
|
-
displayMode?: DisplayMode;
|
|
45
|
-
className?: string;
|
|
46
|
-
}) => {
|
|
47
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
48
|
-
const [buttonWidth, setButtonWidth] = useState<number | null>(null);
|
|
49
|
-
const { user, signIn, signOut } = useUser();
|
|
50
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
51
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (buttonRef.current) {
|
|
55
|
-
setButtonWidth(buttonRef.current.offsetWidth);
|
|
56
|
-
}
|
|
57
|
-
}, [isOpen]);
|
|
58
|
-
|
|
59
|
-
const handleClickOutside = useCallback((event: MouseEvent) => {
|
|
60
|
-
const target = event.target as HTMLElement;
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
buttonRef.current &&
|
|
64
|
-
dropdownRef.current &&
|
|
65
|
-
!buttonRef.current.contains(target) &&
|
|
66
|
-
!dropdownRef.current.contains(target)
|
|
67
|
-
) {
|
|
68
|
-
setIsOpen(false);
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
const handleSignOut = useCallback(async () => {
|
|
73
|
-
signOut();
|
|
74
|
-
|
|
75
|
-
setIsOpen(false);
|
|
76
|
-
}, [signOut]);
|
|
77
|
-
|
|
78
|
-
const handleSignIn = useCallback(async () => {
|
|
79
|
-
await signIn(displayMode);
|
|
80
|
-
|
|
81
|
-
setIsOpen(false);
|
|
82
|
-
}, [signIn, displayMode]);
|
|
83
|
-
|
|
84
|
-
const handleEscape = useCallback((event: KeyboardEvent) => {
|
|
85
|
-
if (event.key === "Escape") {
|
|
86
|
-
setIsOpen(false);
|
|
87
|
-
}
|
|
88
|
-
}, []);
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (isOpen) {
|
|
92
|
-
window.addEventListener("click", handleClickOutside);
|
|
93
|
-
|
|
94
|
-
window.addEventListener("keydown", handleEscape);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return () => {
|
|
98
|
-
window.removeEventListener("click", handleClickOutside);
|
|
99
|
-
|
|
100
|
-
window.removeEventListener("keydown", handleEscape);
|
|
101
|
-
};
|
|
102
|
-
}, [handleClickOutside, handleEscape, isOpen]);
|
|
103
|
-
|
|
104
|
-
if (user) {
|
|
105
|
-
return (
|
|
106
|
-
<div
|
|
107
|
-
style={{ position: "relative", width: "auto" }}
|
|
108
|
-
id="civic-dropdown-container"
|
|
109
|
-
>
|
|
110
|
-
<button
|
|
111
|
-
ref={buttonRef}
|
|
112
|
-
style={{
|
|
113
|
-
cursor: "pointer",
|
|
114
|
-
display: "flex",
|
|
115
|
-
minWidth: "10rem",
|
|
116
|
-
alignItems: "center",
|
|
117
|
-
justifyContent: "space-between",
|
|
118
|
-
gap: "0.5rem",
|
|
119
|
-
borderRadius: "9999px",
|
|
120
|
-
border: "1px solid #6b7280",
|
|
121
|
-
padding: "0.75rem 1rem",
|
|
122
|
-
color: "#6b7280",
|
|
123
|
-
background: "none",
|
|
124
|
-
transition: "background-color 0.2s",
|
|
125
|
-
}}
|
|
126
|
-
className={className}
|
|
127
|
-
onMouseEnter={(e) =>
|
|
128
|
-
(e.currentTarget.style.backgroundColor = "#f3f4f6")
|
|
129
|
-
}
|
|
130
|
-
onMouseLeave={(e) =>
|
|
131
|
-
(e.currentTarget.style.backgroundColor = "transparent")
|
|
132
|
-
}
|
|
133
|
-
onClick={() => {
|
|
134
|
-
setIsOpen((isOpen) => !isOpen);
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
{user?.picture ? (
|
|
138
|
-
<span
|
|
139
|
-
style={{
|
|
140
|
-
position: "relative",
|
|
141
|
-
display: "flex",
|
|
142
|
-
height: "1.5rem",
|
|
143
|
-
width: "1.5rem",
|
|
144
|
-
flexShrink: 0,
|
|
145
|
-
gap: "0.5rem",
|
|
146
|
-
overflow: "hidden",
|
|
147
|
-
borderRadius: "9999px",
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
<img
|
|
151
|
-
style={{ height: "100%", width: "100%", objectFit: "cover" }}
|
|
152
|
-
src={user.picture}
|
|
153
|
-
alt={user?.name || user?.email}
|
|
154
|
-
/>
|
|
155
|
-
</span>
|
|
156
|
-
) : (
|
|
157
|
-
<div />
|
|
158
|
-
)}
|
|
159
|
-
|
|
160
|
-
<span>{user?.name || user?.email}</span>
|
|
161
|
-
|
|
162
|
-
<div style={{ pointerEvents: "none" }}>
|
|
163
|
-
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
164
|
-
</div>
|
|
165
|
-
</button>
|
|
166
|
-
<div
|
|
167
|
-
ref={dropdownRef}
|
|
168
|
-
style={
|
|
169
|
-
isOpen
|
|
170
|
-
? {
|
|
171
|
-
position: "absolute",
|
|
172
|
-
left: 0,
|
|
173
|
-
width: buttonWidth || "auto",
|
|
174
|
-
marginTop: "0.5rem",
|
|
175
|
-
borderRadius: "0.5rem",
|
|
176
|
-
backgroundColor: "white",
|
|
177
|
-
padding: "0.5rem 0",
|
|
178
|
-
color: "#6b7280",
|
|
179
|
-
boxShadow:
|
|
180
|
-
"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
181
|
-
}
|
|
182
|
-
: { display: "none" }
|
|
183
|
-
}
|
|
184
|
-
>
|
|
185
|
-
<ul style={{ listStyleType: "none", margin: 0, padding: 0 }}>
|
|
186
|
-
<li>
|
|
187
|
-
<button
|
|
188
|
-
style={{
|
|
189
|
-
display: "block",
|
|
190
|
-
width: "100%",
|
|
191
|
-
padding: "0.5rem 1rem",
|
|
192
|
-
transition: "background-color 0.2s",
|
|
193
|
-
background: "none",
|
|
194
|
-
border: "none",
|
|
195
|
-
textAlign: "center",
|
|
196
|
-
cursor: "pointer",
|
|
197
|
-
}}
|
|
198
|
-
onClick={handleSignOut}
|
|
199
|
-
onMouseEnter={(e) =>
|
|
200
|
-
(e.currentTarget.style.backgroundColor = "#f3f4f6")
|
|
201
|
-
}
|
|
202
|
-
onMouseLeave={(e) =>
|
|
203
|
-
(e.currentTarget.style.backgroundColor = "transparent")
|
|
204
|
-
}
|
|
205
|
-
>
|
|
206
|
-
Logout
|
|
207
|
-
</button>
|
|
208
|
-
</li>
|
|
209
|
-
</ul>
|
|
210
|
-
</div>
|
|
211
|
-
</div>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<button
|
|
217
|
-
ref={buttonRef}
|
|
218
|
-
data-testid="sign-in-button"
|
|
219
|
-
style={{
|
|
220
|
-
cursor: "pointer",
|
|
221
|
-
borderRadius: "9999px",
|
|
222
|
-
border: "1px solid #6b7280",
|
|
223
|
-
padding: "0.75rem 1rem",
|
|
224
|
-
background: "none",
|
|
225
|
-
transition: "background-color 0.2s",
|
|
226
|
-
}}
|
|
227
|
-
className={className}
|
|
228
|
-
onMouseEnter={(e) => (e.currentTarget.style.backgroundColor = "#f3f4f6")}
|
|
229
|
-
onMouseLeave={(e) =>
|
|
230
|
-
(e.currentTarget.style.backgroundColor = "transparent")
|
|
231
|
-
}
|
|
232
|
-
onClick={handleSignIn}
|
|
233
|
-
>
|
|
234
|
-
Sign in
|
|
235
|
-
</button>
|
|
236
|
-
);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
export { UserButton };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { CivicAuthIframe } from "@/shared/components/CivicAuthIframe.js";
|
|
2
|
-
export { CivicAuthIframeContainer } from "@/shared/components/CivicAuthIframeContainer.js";
|
|
3
|
-
export { UserButton } from "@/reactjs/components/UserButton.js";
|
|
4
|
-
export { SignInButton } from "@/reactjs/components/SignInButton.js";
|
|
5
|
-
export { SignOutButton } from "@/reactjs/components/SignOutButton.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useUser } from "@/reactjs/hooks/useUser.js";
|
|
2
|
-
export { useToken } from "@/shared/hooks/useToken.js";
|
|
3
|
-
export { useAuth } from "@/shared/hooks/useAuth.js";
|
|
4
|
-
export { useSession } from "@/shared/hooks/useSession.js";
|
|
5
|
-
export { useConfig } from "@/shared/hooks/useConfig.js";
|
|
6
|
-
export { useIframe } from "@/shared/hooks/useIframe.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { AuthContext } from "@/shared/providers/AuthContext.js";
|
|
4
|
-
|
|
5
|
-
const useAuth = () => {
|
|
6
|
-
const context = useContext(AuthContext);
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useAuth must be used within an AuthProvider");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return context;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { useAuth };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import {
|
|
4
|
-
UserContext,
|
|
5
|
-
type UserContextType,
|
|
6
|
-
} from "@/shared/providers/UserProvider.js";
|
|
7
|
-
|
|
8
|
-
const useUser = <
|
|
9
|
-
T extends Record<string, unknown> = Record<string, never>,
|
|
10
|
-
>(): UserContextType<T> => {
|
|
11
|
-
const context = useContext(UserContext);
|
|
12
|
-
|
|
13
|
-
if (!context) {
|
|
14
|
-
throw new Error("useUser must be used within a UserProvider");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return context as UserContextType<T>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { useUser };
|
package/src/reactjs/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// These are the default exports of the project.
|
|
2
|
-
// They are limited by design to ensure that the public API does not expose any internal implementation details.
|
|
3
|
-
// Do not change this without thinking carefully about the impact on the client-facing public API.
|
|
4
|
-
export * from "@/reactjs/hooks/index.js";
|
|
5
|
-
export {
|
|
6
|
-
CivicAuthProvider,
|
|
7
|
-
type CivicAuthProviderProps,
|
|
8
|
-
} from "@/reactjs/providers/index.js";
|
|
9
|
-
export type {
|
|
10
|
-
AuthContextType,
|
|
11
|
-
TokenContextType,
|
|
12
|
-
UserContextType,
|
|
13
|
-
} from "@/reactjs/providers/index.js";
|
|
14
|
-
export { CivicAuthIframeContainer } from "@/shared/components/CivicAuthIframeContainer.js";
|
|
15
|
-
export {
|
|
16
|
-
UserButton,
|
|
17
|
-
SignInButton,
|
|
18
|
-
SignOutButton,
|
|
19
|
-
} from "@/reactjs/components/index.js";
|