@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
package/src/nextjs/cookies.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import type { SessionData, UnknownObject, User } from "@/types.js";
|
|
2
|
-
import type { AuthConfig } from "@/nextjs/config.js";
|
|
3
|
-
import { cookies } from "next/headers.js";
|
|
4
|
-
import { GenericUserSession } from "@/shared/lib/UserSession.js";
|
|
5
|
-
import { clearTokens } from "@/shared/lib/util.js";
|
|
6
|
-
import type {
|
|
7
|
-
CodeVerifier,
|
|
8
|
-
CookieConfig,
|
|
9
|
-
OAuthTokens,
|
|
10
|
-
TokensCookieConfig,
|
|
11
|
-
} from "@/shared/lib/types.js";
|
|
12
|
-
import {
|
|
13
|
-
CookieStorage,
|
|
14
|
-
type CookieStorageSettings,
|
|
15
|
-
} from "@/shared/lib/storage.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates HTTP-only cookies for authentication tokens
|
|
19
|
-
*/
|
|
20
|
-
const createTokenCookies = (
|
|
21
|
-
response: Response,
|
|
22
|
-
sessionData: SessionData,
|
|
23
|
-
config: AuthConfig,
|
|
24
|
-
) => {
|
|
25
|
-
const maxAge = sessionData.expiresIn ?? 3600;
|
|
26
|
-
const cookieOptions = {
|
|
27
|
-
...config.cookies?.tokens,
|
|
28
|
-
maxAge,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (sessionData.accessToken) {
|
|
32
|
-
setCookie(response, "access_token", sessionData.accessToken, {
|
|
33
|
-
...cookieOptions,
|
|
34
|
-
httpOnly: true,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (sessionData.idToken) {
|
|
39
|
-
setCookie(response, "id_token", sessionData.idToken, {
|
|
40
|
-
...cookieOptions,
|
|
41
|
-
httpOnly: true,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (sessionData.refreshToken) {
|
|
46
|
-
setCookie(response, "refresh_token", sessionData.refreshToken, {
|
|
47
|
-
...cookieOptions,
|
|
48
|
-
httpOnly: true,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const setCookie = (
|
|
54
|
-
response: Response,
|
|
55
|
-
key: string,
|
|
56
|
-
value: string,
|
|
57
|
-
cookieData: CookieConfig,
|
|
58
|
-
) => {
|
|
59
|
-
response.headers.set(
|
|
60
|
-
"Set-Cookie",
|
|
61
|
-
`${key}=${value}; Path=${cookieData.path}; Domain=${cookieData.domain}; Max-Age=${cookieData.maxAge}; Secure; HttpOnly; SameSite=${cookieData.sameSite}`,
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Creates a client-readable cookie with user info
|
|
67
|
-
*/
|
|
68
|
-
const createUserInfoCookie = (
|
|
69
|
-
response: Response,
|
|
70
|
-
user: User<UnknownObject> | null,
|
|
71
|
-
sessionData: SessionData,
|
|
72
|
-
config: AuthConfig,
|
|
73
|
-
) => {
|
|
74
|
-
if (!user) {
|
|
75
|
-
// unset the "user" cookie
|
|
76
|
-
setCookie(response, "user", "", {
|
|
77
|
-
...config.cookies?.user,
|
|
78
|
-
maxAge: 0,
|
|
79
|
-
});
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const maxAge = sessionData.expiresIn ?? 3600;
|
|
83
|
-
|
|
84
|
-
// TODO select fields to include in the user cookie
|
|
85
|
-
const frontendUser = {
|
|
86
|
-
...user,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// TODO make call to get user info from the
|
|
90
|
-
// auth server /userinfo endpoint when it's available
|
|
91
|
-
// then add to the default claims above
|
|
92
|
-
|
|
93
|
-
setCookie(response, "user", JSON.stringify(frontendUser), {
|
|
94
|
-
...config.cookies?.user,
|
|
95
|
-
maxAge,
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Clears all authentication cookies
|
|
101
|
-
*/
|
|
102
|
-
const clearAuthCookies = async (config: AuthConfig) => {
|
|
103
|
-
// clear session, and tokens
|
|
104
|
-
const cookieStorage = new NextjsCookieStorage(config.cookies?.tokens);
|
|
105
|
-
await clearTokens(cookieStorage);
|
|
106
|
-
|
|
107
|
-
// clear user
|
|
108
|
-
const clientStorage = new NextjsClientStorage();
|
|
109
|
-
const userSession = new GenericUserSession(clientStorage);
|
|
110
|
-
await userSession.set(null);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
type KeySetter = OAuthTokens | CodeVerifier;
|
|
114
|
-
class NextjsCookieStorage extends CookieStorage {
|
|
115
|
-
constructor(readonly config: Partial<TokensCookieConfig> = {}) {
|
|
116
|
-
super({
|
|
117
|
-
secure: true,
|
|
118
|
-
httpOnly: true,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async get(key: string): Promise<string | null> {
|
|
123
|
-
const cookieStore = await cookies();
|
|
124
|
-
return cookieStore.get(key)?.value || null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async set(key: KeySetter, value: string): Promise<void> {
|
|
128
|
-
const cookieStore = await cookies();
|
|
129
|
-
const cookieSettings = this.config?.[key as KeySetter] || {
|
|
130
|
-
...this.settings,
|
|
131
|
-
};
|
|
132
|
-
cookieStore.set(key, value, cookieSettings);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
class NextjsClientStorage extends CookieStorage {
|
|
137
|
-
constructor(config: Partial<CookieStorageSettings> = {}) {
|
|
138
|
-
super({
|
|
139
|
-
...config,
|
|
140
|
-
secure: false,
|
|
141
|
-
httpOnly: false,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async get(key: string): Promise<string | null> {
|
|
146
|
-
const cookieStore = await cookies();
|
|
147
|
-
return cookieStore.get(key)?.value || null;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async set(key: string, value: string): Promise<void> {
|
|
151
|
-
const cookieStore = await cookies();
|
|
152
|
-
cookieStore.set(key, value, this.settings);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export {
|
|
157
|
-
createTokenCookies,
|
|
158
|
-
createUserInfoCookie,
|
|
159
|
-
clearAuthCookies,
|
|
160
|
-
NextjsCookieStorage,
|
|
161
|
-
NextjsClientStorage,
|
|
162
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useTokenCookie } from "@/nextjs/hooks/useTokenCookie.js";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useRouter } from "next/navigation.js";
|
|
4
|
-
import { useQuery } from "@tanstack/react-query";
|
|
5
|
-
import { getWindowCookieValue } from "@/lib/cookies.js";
|
|
6
|
-
import type { OAuthTokens } from "@/shared/lib/types.js";
|
|
7
|
-
|
|
8
|
-
const getTokenFromCookie = (tokenName: OAuthTokens): string => {
|
|
9
|
-
return getWindowCookieValue({
|
|
10
|
-
key: tokenName,
|
|
11
|
-
window: globalThis.window,
|
|
12
|
-
parseJson: false,
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const useTokenCookie = (tokenName: OAuthTokens): string | null => {
|
|
17
|
-
const hasRunRef = useRef(false);
|
|
18
|
-
const router = useRouter();
|
|
19
|
-
|
|
20
|
-
const { data: token } = useQuery({
|
|
21
|
-
queryKey: ["token", tokenName],
|
|
22
|
-
queryFn: () => getTokenFromCookie(tokenName) || null,
|
|
23
|
-
refetchInterval: 2000,
|
|
24
|
-
refetchIntervalInBackground: true,
|
|
25
|
-
enabled: !hasRunRef.current,
|
|
26
|
-
refetchOnWindowFocus: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (token) {
|
|
31
|
-
if (!hasRunRef.current) {
|
|
32
|
-
hasRunRef.current = true;
|
|
33
|
-
router.refresh();
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
hasRunRef.current = false;
|
|
37
|
-
}
|
|
38
|
-
}, [token, router]);
|
|
39
|
-
|
|
40
|
-
return token ?? null;
|
|
41
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useRouter } from "next/navigation.js";
|
|
4
|
-
import { useQuery } from "@tanstack/react-query";
|
|
5
|
-
import { getWindowCookieValue } from "@/lib/cookies.js";
|
|
6
|
-
import type { EmptyObject, User } from "@/types.js";
|
|
7
|
-
import { UserStorage } from "@/shared/lib/types.js";
|
|
8
|
-
|
|
9
|
-
const getUserFromCookie = () =>
|
|
10
|
-
getWindowCookieValue({
|
|
11
|
-
key: UserStorage.USER,
|
|
12
|
-
window: globalThis.window,
|
|
13
|
-
parseJson: true,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const useUserCookie = <T extends EmptyObject>() => {
|
|
17
|
-
const hasRunRef = useRef(false);
|
|
18
|
-
const router = useRouter();
|
|
19
|
-
|
|
20
|
-
const { data: user } = useQuery({
|
|
21
|
-
queryKey: ["user"],
|
|
22
|
-
queryFn: () => getUserFromCookie() as User<T> | null,
|
|
23
|
-
refetchInterval: 2000,
|
|
24
|
-
refetchIntervalInBackground: true,
|
|
25
|
-
enabled: !hasRunRef.current,
|
|
26
|
-
refetchOnWindowFocus: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (user) {
|
|
31
|
-
if (!hasRunRef.current) {
|
|
32
|
-
hasRunRef.current = true;
|
|
33
|
-
router.refresh();
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
hasRunRef.current = false;
|
|
37
|
-
}
|
|
38
|
-
}, [user, router]);
|
|
39
|
-
|
|
40
|
-
return user ?? null;
|
|
41
|
-
};
|
package/src/nextjs/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { createCivicAuthPlugin } from "@/nextjs/config.js";
|
|
2
|
-
export { getUser } from "@/nextjs/GetUser.js";
|
|
3
|
-
export { handler } from "@/nextjs/routeHandler.js";
|
|
4
|
-
export {
|
|
5
|
-
createTokenCookies,
|
|
6
|
-
createUserInfoCookie,
|
|
7
|
-
clearAuthCookies,
|
|
8
|
-
NextjsCookieStorage,
|
|
9
|
-
NextjsClientStorage,
|
|
10
|
-
} from "@/nextjs/cookies.js";
|
|
11
|
-
export type {
|
|
12
|
-
AuthConfig,
|
|
13
|
-
CookiesConfigObject,
|
|
14
|
-
AuthConfigWithDefaults,
|
|
15
|
-
DefinedAuthConfig,
|
|
16
|
-
} from "@/nextjs/config.js";
|
|
17
|
-
export {
|
|
18
|
-
CivicNextAuthProvider as CivicAuthProvider,
|
|
19
|
-
type NextCivicAuthProviderProps as AuthProviderProps,
|
|
20
|
-
} from "@/nextjs/providers/NextAuthProvider.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { authMiddleware, auth, withAuth } from "@/nextjs/middleware.js";
|
package/src/nextjs/middleware.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authenticates the user on all requests by checking the token cookie
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* Option 1: use if no other middleware (e.g. no next-intl etc)
|
|
6
|
-
* export default authMiddleware();
|
|
7
|
-
*
|
|
8
|
-
* Option 2: use if other middleware is needed - default auth config
|
|
9
|
-
* export default withAuth((request) => {
|
|
10
|
-
* console.log('in custom middleware', request.nextUrl.pathname);
|
|
11
|
-
* return NextResponse.next();
|
|
12
|
-
* })
|
|
13
|
-
*
|
|
14
|
-
* Option 3: use if other middleware is needed - specifying auth config
|
|
15
|
-
* const withCivicAuth = auth({ loginUrl: '/login', include: ['/[.*]/user'] })
|
|
16
|
-
* export default withCivicAuth((request) => {
|
|
17
|
-
* console.log('in custom middleware', request.url);
|
|
18
|
-
* return NextResponse.next();
|
|
19
|
-
* })
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
import type { NextRequest } from "next/server.js";
|
|
23
|
-
import { NextResponse } from "next/server.js";
|
|
24
|
-
import picomatch from "picomatch";
|
|
25
|
-
import type { AuthConfig } from "@/nextjs/config.js";
|
|
26
|
-
import { resolveAuthConfig } from "@/nextjs/config.js";
|
|
27
|
-
|
|
28
|
-
type Middleware = (
|
|
29
|
-
request: NextRequest,
|
|
30
|
-
) => Promise<NextResponse> | NextResponse;
|
|
31
|
-
|
|
32
|
-
// Matches globs:
|
|
33
|
-
// Examples:
|
|
34
|
-
// /user
|
|
35
|
-
// /user/*
|
|
36
|
-
// /user/**/info
|
|
37
|
-
const matchGlob = (pathname: string, globPattern: string) => {
|
|
38
|
-
const matches = picomatch(globPattern);
|
|
39
|
-
return matches(pathname);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Matches globs:
|
|
43
|
-
// Examples:
|
|
44
|
-
// /user
|
|
45
|
-
// /user/*
|
|
46
|
-
// /user/**/info
|
|
47
|
-
const matchesGlobs = (pathname: string, patterns: string[]) =>
|
|
48
|
-
patterns.some((pattern) => {
|
|
49
|
-
if (!pattern) return false;
|
|
50
|
-
console.log("matching", {
|
|
51
|
-
pattern,
|
|
52
|
-
pathname,
|
|
53
|
-
match: matchGlob(pathname, pattern),
|
|
54
|
-
});
|
|
55
|
-
return matchGlob(pathname, pattern);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// internal - used by all exported functions
|
|
59
|
-
const applyAuth = async (
|
|
60
|
-
authConfig: AuthConfig,
|
|
61
|
-
request: NextRequest,
|
|
62
|
-
): Promise<NextResponse | undefined> => {
|
|
63
|
-
const authConfigWithDefaults = resolveAuthConfig(authConfig);
|
|
64
|
-
// Check for any valid auth token
|
|
65
|
-
const isAuthenticated = !!request.cookies.get("id_token");
|
|
66
|
-
|
|
67
|
-
// skip auth check for redirect to login url
|
|
68
|
-
if (
|
|
69
|
-
request.nextUrl.pathname === authConfigWithDefaults.loginUrl &&
|
|
70
|
-
request.method === "GET"
|
|
71
|
-
) {
|
|
72
|
-
console.log("→ Skipping auth check - this is the login URL");
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.include)) {
|
|
77
|
-
console.log("→ Skipping auth check - path not in include patterns");
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.exclude)) {
|
|
82
|
-
console.log("→ Skipping auth check - path in exclude patterns");
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Check for either token type
|
|
87
|
-
if (!isAuthenticated) {
|
|
88
|
-
const loginUrl = new URL(authConfigWithDefaults.loginUrl, request.url);
|
|
89
|
-
console.log("→ No valid token found - redirecting to login", loginUrl);
|
|
90
|
-
return NextResponse.redirect(loginUrl);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
console.log("→ Auth check passed");
|
|
94
|
-
return undefined;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* Use this when auth is the only middleware you need.
|
|
100
|
-
* Usage:
|
|
101
|
-
*
|
|
102
|
-
* export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
export const authMiddleware =
|
|
106
|
-
(authConfig: Partial<AuthConfig> = {}) =>
|
|
107
|
-
async (request: NextRequest): Promise<NextResponse> => {
|
|
108
|
-
const response = await applyAuth(authConfig, request);
|
|
109
|
-
if (response) return response;
|
|
110
|
-
|
|
111
|
-
// NextJS doesn't do middleware chaining yet, so this does not mean
|
|
112
|
-
// "call the next middleware" - it means "continue to the route handler"
|
|
113
|
-
return NextResponse.next();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Usage:
|
|
118
|
-
*
|
|
119
|
-
* export default withAuth(async (request) => {
|
|
120
|
-
* console.log('my middleware');
|
|
121
|
-
* return NextResponse.next();
|
|
122
|
-
* })
|
|
123
|
-
*/
|
|
124
|
-
// use this when you have your own middleware to chain
|
|
125
|
-
export function withAuth(
|
|
126
|
-
middleware: Middleware,
|
|
127
|
-
): (request: NextRequest) => Promise<NextResponse> {
|
|
128
|
-
return auth()(middleware);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)
|
|
133
|
-
*
|
|
134
|
-
* Usage:
|
|
135
|
-
*
|
|
136
|
-
* const withAuth = auth({ loginUrl = '/login' }); // or just auth();
|
|
137
|
-
*
|
|
138
|
-
* export default withAuth(async (request) => {
|
|
139
|
-
* console.log('my middleware');
|
|
140
|
-
* return NextResponse.next();
|
|
141
|
-
* })
|
|
142
|
-
*
|
|
143
|
-
*/
|
|
144
|
-
export function auth(authConfig: AuthConfig = {}) {
|
|
145
|
-
return (
|
|
146
|
-
middleware: Middleware,
|
|
147
|
-
): ((request: NextRequest) => Promise<NextResponse>) => {
|
|
148
|
-
return async (request: NextRequest): Promise<NextResponse> => {
|
|
149
|
-
const response = await applyAuth(authConfig, request);
|
|
150
|
-
if (response) return response;
|
|
151
|
-
|
|
152
|
-
return middleware(request);
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
/**
|
|
3
|
-
* A very small context provider for the user object - it takes the user object from the cookie and provides it to the app.
|
|
4
|
-
*/
|
|
5
|
-
import React, { useEffect, useState } from "react";
|
|
6
|
-
import type { AuthProviderProps } from "@/shared/providers/AuthProvider.js";
|
|
7
|
-
import { AuthProvider } from "@/shared/providers/AuthProvider.js";
|
|
8
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9
|
-
import type { User } from "@/types.js";
|
|
10
|
-
import { resolveAuthConfig } from "@/nextjs/config.js";
|
|
11
|
-
import { resolveCallbackUrl } from "@/nextjs/utils.js";
|
|
12
|
-
import { ConfidentialClientPKCEConsumer } from "@/services/PKCE.js";
|
|
13
|
-
import { NextjsClientStorage } from "@/nextjs/cookies.js";
|
|
14
|
-
import { UserProvider } from "@/shared/providers/UserProvider.js";
|
|
15
|
-
import { OAuthTokens } from "@/shared/lib/types.js";
|
|
16
|
-
import { useUserCookie } from "@/nextjs/hooks/useUserCookie.js";
|
|
17
|
-
import { useTokenCookie } from "@/nextjs/hooks/index.js";
|
|
18
|
-
|
|
19
|
-
const queryClient = new QueryClient();
|
|
20
|
-
|
|
21
|
-
type NextCivicAuthProviderProps = Omit<AuthProviderProps, "clientId">;
|
|
22
|
-
|
|
23
|
-
const CivicNextAuthProviderInternal = ({
|
|
24
|
-
children,
|
|
25
|
-
...props
|
|
26
|
-
}: NextCivicAuthProviderProps) => {
|
|
27
|
-
const [redirectUrl, setRedirectUrl] = useState<string>("");
|
|
28
|
-
const resolvedConfig = resolveAuthConfig();
|
|
29
|
-
const { clientId, oauthServer, callbackUrl, challengeUrl, logoutUrl } =
|
|
30
|
-
resolvedConfig;
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (typeof globalThis.window !== "undefined") {
|
|
34
|
-
const appUrl = globalThis.window.location.origin;
|
|
35
|
-
setRedirectUrl(resolveCallbackUrl(resolvedConfig, appUrl));
|
|
36
|
-
}
|
|
37
|
-
}, [callbackUrl, resolvedConfig]);
|
|
38
|
-
|
|
39
|
-
const user = useUserCookie();
|
|
40
|
-
const idToken = useTokenCookie(OAuthTokens.ID_TOKEN);
|
|
41
|
-
const combinedUser = user ? ({ ...(user || {}), idToken } as User) : null;
|
|
42
|
-
const sessionData = {
|
|
43
|
-
authenticated: !!user,
|
|
44
|
-
...(idToken ? { idToken } : {}),
|
|
45
|
-
};
|
|
46
|
-
const signOut = async (): Promise<void> => {
|
|
47
|
-
if (props.onSignOut) {
|
|
48
|
-
await props.onSignOut();
|
|
49
|
-
}
|
|
50
|
-
const appUrl = globalThis.window.location.origin;
|
|
51
|
-
window.location.href = `${logoutUrl}?appUrl=${appUrl}`;
|
|
52
|
-
return;
|
|
53
|
-
};
|
|
54
|
-
return (
|
|
55
|
-
<AuthProvider
|
|
56
|
-
{...props}
|
|
57
|
-
redirectUrl={redirectUrl}
|
|
58
|
-
config={{ oauthServer }}
|
|
59
|
-
clientId={clientId}
|
|
60
|
-
pkceConsumer={new ConfidentialClientPKCEConsumer(challengeUrl)}
|
|
61
|
-
sessionData={sessionData}
|
|
62
|
-
>
|
|
63
|
-
<UserProvider
|
|
64
|
-
storage={new NextjsClientStorage()}
|
|
65
|
-
user={combinedUser}
|
|
66
|
-
signOut={signOut}
|
|
67
|
-
>
|
|
68
|
-
{children}
|
|
69
|
-
</UserProvider>
|
|
70
|
-
</AuthProvider>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const CivicNextAuthProvider = ({
|
|
75
|
-
children,
|
|
76
|
-
...props
|
|
77
|
-
}: NextCivicAuthProviderProps) => {
|
|
78
|
-
return (
|
|
79
|
-
<QueryClientProvider client={queryClient}>
|
|
80
|
-
<CivicNextAuthProviderInternal {...props}>
|
|
81
|
-
{children}
|
|
82
|
-
</CivicNextAuthProviderInternal>
|
|
83
|
-
</QueryClientProvider>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { CivicNextAuthProvider, type NextCivicAuthProviderProps };
|