@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,51 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import type { JWT } from "oslo/jwt";
|
|
3
|
-
import { parseJWT } from "oslo/jwt";
|
|
4
|
-
import { getUser } from "@/shared/lib/session.js";
|
|
5
|
-
import { retrieveTokens } from "@/shared/lib/util.js";
|
|
6
|
-
import type { AuthStorage, OIDCTokenResponseBody, User } from "@/types.js";
|
|
7
|
-
|
|
8
|
-
vi.mock("@/shared/lib/util.js");
|
|
9
|
-
vi.mock("oslo/jwt");
|
|
10
|
-
|
|
11
|
-
describe("getUser", () => {
|
|
12
|
-
const mockStorage = {} as AuthStorage;
|
|
13
|
-
const mockUser: User = {
|
|
14
|
-
id: "mockUserId",
|
|
15
|
-
email: "user@example.com",
|
|
16
|
-
} as User;
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should return null if no tokens are retrieved", async () => {
|
|
23
|
-
vi.mocked(retrieveTokens).mockResolvedValue(null);
|
|
24
|
-
|
|
25
|
-
const result = await getUser(mockStorage);
|
|
26
|
-
expect(result).toBeNull();
|
|
27
|
-
expect(retrieveTokens).toHaveBeenCalledWith(mockStorage);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should return a User if tokens are retrieved and parsed successfully", async () => {
|
|
31
|
-
const mockTokens = { id_token: "mockIdToken" } as OIDCTokenResponseBody;
|
|
32
|
-
vi.mocked(retrieveTokens).mockResolvedValue(mockTokens);
|
|
33
|
-
vi.mocked(parseJWT).mockReturnValue({ payload: mockUser } as JWT);
|
|
34
|
-
|
|
35
|
-
const result = await getUser(mockStorage);
|
|
36
|
-
expect(result).toEqual(mockUser);
|
|
37
|
-
expect(retrieveTokens).toHaveBeenCalledWith(mockStorage);
|
|
38
|
-
expect(parseJWT).toHaveBeenCalledWith(mockTokens.id_token);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should return null if parsing the ID token fails", async () => {
|
|
42
|
-
const mockTokens = { id_token: "mockIdToken" } as OIDCTokenResponseBody;
|
|
43
|
-
vi.mocked(retrieveTokens).mockResolvedValue(mockTokens);
|
|
44
|
-
vi.mocked(parseJWT).mockReturnValue(null); // Simulate parse failure
|
|
45
|
-
|
|
46
|
-
const result = await getUser(mockStorage);
|
|
47
|
-
expect(result).toBeNull();
|
|
48
|
-
expect(retrieveTokens).toHaveBeenCalledWith(mockStorage);
|
|
49
|
-
expect(parseJWT).toHaveBeenCalledWith(mockTokens.id_token);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
BrowserAuthenticationInitiator,
|
|
4
|
-
BrowserAuthenticationService,
|
|
5
|
-
GenericAuthenticationInitiator,
|
|
6
|
-
} from "@/services/AuthenticationService.js";
|
|
7
|
-
import {
|
|
8
|
-
generateOauthLoginUrl,
|
|
9
|
-
generateOauthLogoutUrl,
|
|
10
|
-
exchangeTokens,
|
|
11
|
-
retrieveTokens,
|
|
12
|
-
storeTokens,
|
|
13
|
-
} from "@/shared/lib/util.js";
|
|
14
|
-
import { LocalStorageAdapter } from "@/browser/storage.js";
|
|
15
|
-
import { BrowserPublicClientPKCEProducer } from "@/services/PKCE.js";
|
|
16
|
-
import type { OIDCTokenResponseBody, SessionData } from "@/types.js";
|
|
17
|
-
import type { AuthenticationResolver, PKCEConsumer } from "@/services/types.js";
|
|
18
|
-
|
|
19
|
-
vi.mock("@/shared/lib/util.js", () => ({
|
|
20
|
-
getEndpointsWithOverrides: async () => ({
|
|
21
|
-
auth: "auth-endpoint",
|
|
22
|
-
}),
|
|
23
|
-
exchangeTokens: vi.fn(),
|
|
24
|
-
retrieveTokens: vi.fn(),
|
|
25
|
-
storeTokens: vi.fn(),
|
|
26
|
-
generateOauthLoginUrl: vi.fn(),
|
|
27
|
-
generateOauthLogoutUrl: vi.fn(),
|
|
28
|
-
clearTokens: vi.fn(),
|
|
29
|
-
clearUser: vi.fn(),
|
|
30
|
-
}));
|
|
31
|
-
vi.mock("@/browser/storage");
|
|
32
|
-
vi.mock("@/services/PKCE.js");
|
|
33
|
-
|
|
34
|
-
describe("Authentication Services", () => {
|
|
35
|
-
const mockConfig = {
|
|
36
|
-
clientId: "mockClientId",
|
|
37
|
-
redirectUrl: "http://localhost/redirect",
|
|
38
|
-
state: "mockState",
|
|
39
|
-
scopes: ["openid", "profile"],
|
|
40
|
-
displayMode: "redirect" as const,
|
|
41
|
-
oauthServer: "http://mockOauthServer",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
describe("BrowserAuthenticationInitiator", () => {
|
|
45
|
-
it("should generate a login URL", async () => {
|
|
46
|
-
const initiator = new BrowserAuthenticationInitiator({
|
|
47
|
-
...mockConfig,
|
|
48
|
-
pkceConsumer: {} as PKCEConsumer,
|
|
49
|
-
});
|
|
50
|
-
vi.mocked(generateOauthLoginUrl).mockResolvedValue(
|
|
51
|
-
new URL("http://mockLoginUrl"),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const url = await initiator.signIn({} as HTMLIFrameElement);
|
|
55
|
-
|
|
56
|
-
expect(url.toString()).toBe("http://mockloginurl/");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should generate a logout URL", async () => {
|
|
60
|
-
const initiator = new BrowserAuthenticationInitiator({
|
|
61
|
-
...mockConfig,
|
|
62
|
-
pkceConsumer: {} as PKCEConsumer,
|
|
63
|
-
});
|
|
64
|
-
vi.mocked(generateOauthLogoutUrl).mockResolvedValue(
|
|
65
|
-
new URL("http://mocklogouturl"),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const url = await initiator.signOut();
|
|
69
|
-
|
|
70
|
-
expect(url.toString()).toBe("http://mocklogouturl/");
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("GenericAuthenticationInitiator", () => {
|
|
75
|
-
it("should generate a login URL", async () => {
|
|
76
|
-
const initiator = new GenericAuthenticationInitiator({
|
|
77
|
-
...mockConfig,
|
|
78
|
-
pkceConsumer: {} as PKCEConsumer,
|
|
79
|
-
});
|
|
80
|
-
vi.mocked(generateOauthLoginUrl).mockResolvedValue(
|
|
81
|
-
new URL("http://mockloginurl"),
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const url = await initiator.signIn();
|
|
85
|
-
|
|
86
|
-
expect(url.toString()).toBe("http://mockloginurl/");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should generate a logout URL", async () => {
|
|
90
|
-
const initiator = new GenericAuthenticationInitiator({
|
|
91
|
-
...mockConfig,
|
|
92
|
-
pkceConsumer: {} as PKCEConsumer,
|
|
93
|
-
});
|
|
94
|
-
vi.mocked(generateOauthLogoutUrl).mockResolvedValue(
|
|
95
|
-
new URL("http://mocklogouturl"),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const url = await initiator.signOut();
|
|
99
|
-
|
|
100
|
-
expect(url.toString()).toBe("http://mocklogouturl/");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("BrowserAuthenticationService", () => {
|
|
105
|
-
let service: AuthenticationResolver;
|
|
106
|
-
const mockTokens: OIDCTokenResponseBody = {
|
|
107
|
-
id_token: "mockIdToken",
|
|
108
|
-
access_token: "mockAccessToken",
|
|
109
|
-
refresh_token: "mockRefreshToken",
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
beforeEach(async () => {
|
|
113
|
-
service = await BrowserAuthenticationService.build({
|
|
114
|
-
...mockConfig,
|
|
115
|
-
});
|
|
116
|
-
vi.mocked(exchangeTokens).mockResolvedValue(mockTokens);
|
|
117
|
-
vi.mocked(retrieveTokens).mockResolvedValue(mockTokens);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("should exchange auth code for tokens and store them", async () => {
|
|
121
|
-
const code = "mockCode";
|
|
122
|
-
const state = "mockState";
|
|
123
|
-
|
|
124
|
-
vi.mocked(
|
|
125
|
-
BrowserPublicClientPKCEProducer.prototype.getCodeVerifier,
|
|
126
|
-
).mockResolvedValue("dummy-verifier");
|
|
127
|
-
|
|
128
|
-
const tokens = await service.tokenExchange(code, state);
|
|
129
|
-
|
|
130
|
-
expect(storeTokens).toHaveBeenCalledWith(
|
|
131
|
-
expect.any(LocalStorageAdapter),
|
|
132
|
-
mockTokens,
|
|
133
|
-
);
|
|
134
|
-
expect(tokens).toEqual(mockTokens);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should retrieve session data from local storage", async () => {
|
|
138
|
-
const sessionData: SessionData = {
|
|
139
|
-
authenticated: true,
|
|
140
|
-
idToken: mockTokens.id_token,
|
|
141
|
-
accessToken: mockTokens.access_token,
|
|
142
|
-
refreshToken: mockTokens.refresh_token,
|
|
143
|
-
};
|
|
144
|
-
const result = await service.getSessionData();
|
|
145
|
-
|
|
146
|
-
expect(retrieveTokens).toHaveBeenCalledWith(
|
|
147
|
-
expect.any(LocalStorageAdapter),
|
|
148
|
-
);
|
|
149
|
-
expect(result).toEqual(sessionData);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { ServerAuthenticationResolver } from "@/server/ServerAuthenticationResolver.js";
|
|
3
|
-
import {
|
|
4
|
-
exchangeTokens,
|
|
5
|
-
getEndpointsWithOverrides,
|
|
6
|
-
retrieveTokens,
|
|
7
|
-
storeTokens,
|
|
8
|
-
} from "@/shared/lib/util.js";
|
|
9
|
-
import type {
|
|
10
|
-
AuthStorage,
|
|
11
|
-
Endpoints,
|
|
12
|
-
OIDCTokenResponseBody,
|
|
13
|
-
SessionData,
|
|
14
|
-
} from "@/types.js";
|
|
15
|
-
import type { AuthConfig } from "@/server/config.ts";
|
|
16
|
-
import { GenericPublicClientPKCEProducer } from "@/services/PKCE.js";
|
|
17
|
-
import type { AuthenticationResolver } from "@/services/types.ts";
|
|
18
|
-
|
|
19
|
-
vi.mock("oslo/oauth2");
|
|
20
|
-
vi.mock("@/services/PKCE.js");
|
|
21
|
-
vi.mock("@/shared/lib/util.js");
|
|
22
|
-
|
|
23
|
-
describe("ServerAuthenticationResolver", () => {
|
|
24
|
-
const mockAuthConfig: AuthConfig = {
|
|
25
|
-
clientId: "mockClientId",
|
|
26
|
-
oauthServer: "http://mockOauthServer",
|
|
27
|
-
redirectUrl: "http://localhost/redirect",
|
|
28
|
-
challengeUrl: "http://localhost/challenge",
|
|
29
|
-
};
|
|
30
|
-
const mockEndpoints: Endpoints = {
|
|
31
|
-
auth: "http://mockAuthEndpoint",
|
|
32
|
-
token: "http://mockTokenEndpoint",
|
|
33
|
-
jwks: "http://mockJwksEndpoint",
|
|
34
|
-
userinfo: "http://mockUserinfoEndpoint",
|
|
35
|
-
};
|
|
36
|
-
const mockTokens: OIDCTokenResponseBody = {
|
|
37
|
-
id_token: "mockIdToken",
|
|
38
|
-
access_token: "mockAccessToken",
|
|
39
|
-
refresh_token: "mockRefreshToken",
|
|
40
|
-
};
|
|
41
|
-
const mockStorage = {} as AuthStorage;
|
|
42
|
-
|
|
43
|
-
let resolver: AuthenticationResolver;
|
|
44
|
-
|
|
45
|
-
beforeEach(async () => {
|
|
46
|
-
vi.clearAllMocks();
|
|
47
|
-
vi.mocked(getEndpointsWithOverrides).mockResolvedValue(mockEndpoints);
|
|
48
|
-
resolver = await ServerAuthenticationResolver.build(
|
|
49
|
-
mockAuthConfig,
|
|
50
|
-
mockStorage,
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("init", () => {
|
|
55
|
-
it("should initialize OAuth2 client with resolved endpoints", async () => {
|
|
56
|
-
expect(getEndpointsWithOverrides).toHaveBeenCalledWith(
|
|
57
|
-
mockAuthConfig.oauthServer,
|
|
58
|
-
undefined,
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("tokenExchange", () => {
|
|
64
|
-
it("should exchange auth code for tokens and store them", async () => {
|
|
65
|
-
const code = "mockCode";
|
|
66
|
-
const state = "mockState";
|
|
67
|
-
const codeVerifier = "mockCodeVerifier";
|
|
68
|
-
vi.mocked(
|
|
69
|
-
GenericPublicClientPKCEProducer.prototype.getCodeVerifier,
|
|
70
|
-
).mockResolvedValue(codeVerifier);
|
|
71
|
-
vi.mocked(exchangeTokens).mockResolvedValue(mockTokens);
|
|
72
|
-
|
|
73
|
-
const tokens = await resolver.tokenExchange(code, state);
|
|
74
|
-
|
|
75
|
-
expect(storeTokens).toHaveBeenCalledWith(mockStorage, mockTokens);
|
|
76
|
-
expect(tokens).toEqual(mockTokens);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("should throw an error if code verifier is not found", async () => {
|
|
80
|
-
vi.mocked(
|
|
81
|
-
GenericPublicClientPKCEProducer.prototype.getCodeVerifier,
|
|
82
|
-
).mockResolvedValue(null);
|
|
83
|
-
|
|
84
|
-
await expect(
|
|
85
|
-
resolver.tokenExchange("mockCode", "mockState"),
|
|
86
|
-
).rejects.toThrow("Code verifier not found in storage");
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe("getSessionData", () => {
|
|
91
|
-
it("should retrieve session data from storage", async () => {
|
|
92
|
-
vi.mocked(retrieveTokens).mockResolvedValue(mockTokens);
|
|
93
|
-
|
|
94
|
-
const sessionData: SessionData = {
|
|
95
|
-
authenticated: true,
|
|
96
|
-
idToken: mockTokens.id_token,
|
|
97
|
-
accessToken: mockTokens.access_token,
|
|
98
|
-
refreshToken: mockTokens.refresh_token,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const result = await resolver.getSessionData();
|
|
102
|
-
|
|
103
|
-
expect(retrieveTokens).toHaveBeenCalledWith(mockStorage);
|
|
104
|
-
expect(result).toEqual(sessionData);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should return null if no tokens are found in storage", async () => {
|
|
108
|
-
vi.mocked(retrieveTokens).mockResolvedValue(null);
|
|
109
|
-
|
|
110
|
-
const result = await resolver.getSessionData();
|
|
111
|
-
|
|
112
|
-
expect(result).toBeNull();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GenericAuthenticationRefresher } from "@/shared/lib/GenericAuthenticationRefresher.js";
|
|
3
|
-
import {
|
|
4
|
-
getEndpointsWithOverrides,
|
|
5
|
-
retrieveTokens,
|
|
6
|
-
storeTokens,
|
|
7
|
-
} from "@/shared/lib/util.js";
|
|
8
|
-
import type { AuthStorage, Endpoints, OIDCTokenResponseBody } from "@/types.js";
|
|
9
|
-
import { OAuth2Client } from "oslo/oauth2";
|
|
10
|
-
import type { AuthConfig } from "@/server/config.ts";
|
|
11
|
-
|
|
12
|
-
vi.mock("@/shared/lib/util.js");
|
|
13
|
-
vi.mock("oslo/oauth2");
|
|
14
|
-
|
|
15
|
-
describe("GenericAuthenticationRefresher", () => {
|
|
16
|
-
const mockAuthConfig: AuthConfig = {
|
|
17
|
-
clientId: "mockClientId",
|
|
18
|
-
oauthServer: "http://mockOauthServer",
|
|
19
|
-
redirectUrl: "http://localhost/redirect",
|
|
20
|
-
};
|
|
21
|
-
const mockEndpoints: Endpoints = {
|
|
22
|
-
auth: "http://mockAuthEndpoint",
|
|
23
|
-
token: "http://mockTokenEndpoint",
|
|
24
|
-
jwks: "http://mockJwksEndpoint",
|
|
25
|
-
userinfo: "http://mockUserinfoEndpoint",
|
|
26
|
-
};
|
|
27
|
-
const mockTokens: OIDCTokenResponseBody = {
|
|
28
|
-
id_token: "mockIdToken",
|
|
29
|
-
access_token: "mockAccessToken",
|
|
30
|
-
refresh_token: "mockRefreshToken",
|
|
31
|
-
};
|
|
32
|
-
const mockStorage = {} as AuthStorage;
|
|
33
|
-
|
|
34
|
-
let refresher: GenericAuthenticationRefresher;
|
|
35
|
-
|
|
36
|
-
beforeEach(async () => {
|
|
37
|
-
vi.clearAllMocks();
|
|
38
|
-
vi.mocked(getEndpointsWithOverrides).mockResolvedValue(mockEndpoints);
|
|
39
|
-
refresher = await GenericAuthenticationRefresher.build(
|
|
40
|
-
mockAuthConfig,
|
|
41
|
-
mockStorage,
|
|
42
|
-
);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("init", () => {
|
|
46
|
-
it("should initialize OAuth2 client with resolved endpoints", async () => {
|
|
47
|
-
expect(getEndpointsWithOverrides).toHaveBeenCalledWith(
|
|
48
|
-
mockAuthConfig.oauthServer,
|
|
49
|
-
undefined,
|
|
50
|
-
);
|
|
51
|
-
expect(refresher["endpoints"]).toEqual(mockEndpoints);
|
|
52
|
-
expect(refresher["oauth2client"]).toBeInstanceOf(OAuth2Client);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("refreshTokens", () => {
|
|
57
|
-
it("should refresh tokens and store them", async () => {
|
|
58
|
-
vi.mocked(retrieveTokens).mockResolvedValue(mockTokens);
|
|
59
|
-
const refreshedTokens: OIDCTokenResponseBody = {
|
|
60
|
-
id_token: "newIdToken",
|
|
61
|
-
access_token: "newAccessToken",
|
|
62
|
-
refresh_token: "newRefreshToken",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
vi.mocked(OAuth2Client.prototype.refreshAccessToken).mockResolvedValue(
|
|
66
|
-
refreshedTokens,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const result = await refresher.refreshTokens();
|
|
70
|
-
|
|
71
|
-
expect(
|
|
72
|
-
refresher["oauth2client"]?.refreshAccessToken,
|
|
73
|
-
).toHaveBeenCalledWith(mockTokens.refresh_token);
|
|
74
|
-
expect(storeTokens).toHaveBeenCalledWith(mockStorage, refreshedTokens);
|
|
75
|
-
expect(result).toEqual(mockTokens);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("should throw an error if no refresh token is available", async () => {
|
|
79
|
-
vi.mocked(retrieveTokens).mockResolvedValue({
|
|
80
|
-
...mockTokens,
|
|
81
|
-
refresh_token: undefined,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
await expect(refresher.refreshTokens()).rejects.toThrow(
|
|
85
|
-
"No refresh token available",
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { GenericUserSession } from "@/shared/lib/UserSession.js";
|
|
3
|
-
import type { AuthStorage, User } from "@/types.ts";
|
|
4
|
-
|
|
5
|
-
const mockUser: User = {
|
|
6
|
-
id: "user123",
|
|
7
|
-
name: "John Doe",
|
|
8
|
-
email: "john@example.com",
|
|
9
|
-
picture: "https://example.com/john.jpg",
|
|
10
|
-
forwardedTokens: null,
|
|
11
|
-
} as unknown as User;
|
|
12
|
-
|
|
13
|
-
let storage: Record<string, string> = {};
|
|
14
|
-
class TestStorage implements AuthStorage {
|
|
15
|
-
async get(key: string): Promise<string | null> {
|
|
16
|
-
return storage[key] ?? null;
|
|
17
|
-
}
|
|
18
|
-
async set(key: string, value: string): Promise<void> {
|
|
19
|
-
storage[key] = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("UserSession", () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
storage = {}; // clear storage
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe("GenericUserSession", () => {
|
|
29
|
-
it("should get the user from session", async () => {
|
|
30
|
-
const userSession = new GenericUserSession(new TestStorage());
|
|
31
|
-
userSession.set(mockUser);
|
|
32
|
-
const user = await userSession.get();
|
|
33
|
-
expect(user).toEqual(mockUser);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("should return null if user it not found", async () => {
|
|
37
|
-
const userSession = new GenericUserSession(new TestStorage());
|
|
38
|
-
const user = await userSession.get();
|
|
39
|
-
expect(user).toBeNull();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { render, act, waitFor } from "@testing-library/react";
|
|
2
|
-
import { CivicAuthIframeContainer } from "@/shared/components/CivicAuthIframeContainer.js";
|
|
3
|
-
import { vi } from "vitest";
|
|
4
|
-
import React, { type RefObject } from "react";
|
|
5
|
-
import { createRef } from "react";
|
|
6
|
-
import { TOKEN_EXCHANGE_TRIGGER_TEXT } from "@/constants.js";
|
|
7
|
-
|
|
8
|
-
let setAuthResponseUrlMock: any;
|
|
9
|
-
let iframeRefMock: RefObject<HTMLIFrameElement>;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
iframeRefMock = createRef();
|
|
13
|
-
|
|
14
|
-
vi.mock("@/shared/hooks", () => ({
|
|
15
|
-
useAuth: () => ({ isLoading: false }),
|
|
16
|
-
useConfig: () => ({
|
|
17
|
-
redirectUrl: "https://example.com/redirect",
|
|
18
|
-
modalIframe: true,
|
|
19
|
-
}),
|
|
20
|
-
useIframe: vi.fn(() => ({
|
|
21
|
-
setAuthResponseUrl: setAuthResponseUrlMock,
|
|
22
|
-
iframeRef: iframeRefMock,
|
|
23
|
-
})),
|
|
24
|
-
}));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe("CivicAuthIframeContainer", () => {
|
|
28
|
-
let originalFetch: typeof global.fetch;
|
|
29
|
-
|
|
30
|
-
beforeAll(() => {
|
|
31
|
-
originalFetch = global.fetch;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterAll(() => {
|
|
35
|
-
global.fetch = originalFetch;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it(`triggers a fetch request when '${TOKEN_EXCHANGE_TRIGGER_TEXT}' is in the iframe body`, async () => {
|
|
39
|
-
const onCloseMock = vi.fn();
|
|
40
|
-
setAuthResponseUrlMock = vi.fn();
|
|
41
|
-
|
|
42
|
-
const fetchMock = vi.fn(() => Promise.resolve({ ok: true }));
|
|
43
|
-
global.fetch = fetchMock as any;
|
|
44
|
-
|
|
45
|
-
render(
|
|
46
|
-
<CivicAuthIframeContainer onClose={onCloseMock} closeOnRedirect={true} />,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
act(() => {
|
|
50
|
-
if (iframeRefMock.current) {
|
|
51
|
-
Object.defineProperty(iframeRefMock.current, "contentWindow", {
|
|
52
|
-
value: {
|
|
53
|
-
location: {
|
|
54
|
-
href: "https://example.com/redirect?code=1234",
|
|
55
|
-
},
|
|
56
|
-
document: {
|
|
57
|
-
body: {
|
|
58
|
-
innerHTML: TOKEN_EXCHANGE_TRIGGER_TEXT,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
configurable: true,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
act(() => {
|
|
68
|
-
iframeRefMock.current?.dispatchEvent(new Event("load"));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await waitFor(() => {
|
|
72
|
-
expect(fetchMock).toHaveBeenCalledWith(
|
|
73
|
-
"https://example.com/redirect?code=1234&appUrl=http://localhost:3000",
|
|
74
|
-
);
|
|
75
|
-
expect(onCloseMock).toHaveBeenCalled();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it(`sets auth response URL when no '${TOKEN_EXCHANGE_TRIGGER_TEXT}' in iframe body`, async () => {
|
|
80
|
-
const onCloseMock = vi.fn();
|
|
81
|
-
setAuthResponseUrlMock = vi.fn();
|
|
82
|
-
|
|
83
|
-
render(
|
|
84
|
-
<CivicAuthIframeContainer onClose={onCloseMock} closeOnRedirect={true} />,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
act(() => {
|
|
88
|
-
if (iframeRefMock.current) {
|
|
89
|
-
Object.defineProperty(iframeRefMock.current, "contentWindow", {
|
|
90
|
-
value: {
|
|
91
|
-
location: {
|
|
92
|
-
href: "https://example.com/redirect?code=5678",
|
|
93
|
-
},
|
|
94
|
-
document: {
|
|
95
|
-
body: {
|
|
96
|
-
innerHTML: "",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
configurable: true,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
act(() => {
|
|
106
|
-
iframeRefMock.current?.dispatchEvent(new Event("load"));
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
await waitFor(() => {
|
|
110
|
-
expect(setAuthResponseUrlMock).toHaveBeenCalledWith(
|
|
111
|
-
"https://example.com/redirect?code=5678",
|
|
112
|
-
);
|
|
113
|
-
expect(onCloseMock).toHaveBeenCalled();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("does not call onClose if closeOnRedirect is false", async () => {
|
|
118
|
-
const onCloseMock = vi.fn();
|
|
119
|
-
setAuthResponseUrlMock = vi.fn();
|
|
120
|
-
|
|
121
|
-
render(
|
|
122
|
-
<CivicAuthIframeContainer
|
|
123
|
-
onClose={onCloseMock}
|
|
124
|
-
closeOnRedirect={false}
|
|
125
|
-
/>,
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
act(() => {
|
|
129
|
-
if (iframeRefMock.current) {
|
|
130
|
-
Object.defineProperty(iframeRefMock.current, "contentWindow", {
|
|
131
|
-
value: {
|
|
132
|
-
location: {
|
|
133
|
-
href: "https://example.com/redirect?code=91011",
|
|
134
|
-
},
|
|
135
|
-
document: {
|
|
136
|
-
body: {
|
|
137
|
-
innerHTML: TOKEN_EXCHANGE_TRIGGER_TEXT,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
configurable: true,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
act(() => {
|
|
147
|
-
iframeRefMock.current?.dispatchEvent(new Event("load"));
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
await waitFor(() => {
|
|
151
|
-
expect(onCloseMock).not.toHaveBeenCalled();
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
CookieStorage,
|
|
4
|
-
DEFAULT_COOKIE_DURATION,
|
|
5
|
-
type CookieStorageSettings,
|
|
6
|
-
} from "@/shared/lib/storage.js";
|
|
7
|
-
|
|
8
|
-
describe("CookieStorage", () => {
|
|
9
|
-
class MockCookieStorage extends CookieStorage {
|
|
10
|
-
private storage: Record<string, string> = {};
|
|
11
|
-
|
|
12
|
-
constructor(settings: Partial<CookieStorageSettings>) {
|
|
13
|
-
super(settings);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async get(key: string): Promise<string | null> {
|
|
17
|
-
return this.storage[key] ?? null;
|
|
18
|
-
}
|
|
19
|
-
async set(key: string, value: string): Promise<void> {
|
|
20
|
-
this.storage[key] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
it("should set default settings if none are provided", () => {
|
|
25
|
-
const storage = new MockCookieStorage({});
|
|
26
|
-
|
|
27
|
-
const expectedSettings: CookieStorageSettings = {
|
|
28
|
-
httpOnly: true,
|
|
29
|
-
secure: true,
|
|
30
|
-
sameSite: "lax",
|
|
31
|
-
expires: new Date(Date.now() + 1000 * DEFAULT_COOKIE_DURATION),
|
|
32
|
-
path: "/",
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
expect(storage["settings"]).toMatchObject({
|
|
36
|
-
httpOnly: expectedSettings.httpOnly,
|
|
37
|
-
secure: expectedSettings.secure,
|
|
38
|
-
sameSite: expectedSettings.sameSite,
|
|
39
|
-
path: expectedSettings.path,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const expires = storage["settings"].expires;
|
|
43
|
-
const expectedExpires = expectedSettings.expires;
|
|
44
|
-
expect(expires.getTime()).toBeCloseTo(expectedExpires.getTime(), -3); // Allow small time diff tolerance
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should allow custom settings to override defaults", () => {
|
|
48
|
-
const customSettings: Partial<CookieStorageSettings> = {
|
|
49
|
-
httpOnly: false,
|
|
50
|
-
secure: false,
|
|
51
|
-
sameSite: "strict",
|
|
52
|
-
expires: new Date(Date.now() + 1000 * 60 * 30), // 30 minutes
|
|
53
|
-
path: "/custom",
|
|
54
|
-
};
|
|
55
|
-
const storage = new MockCookieStorage(customSettings);
|
|
56
|
-
|
|
57
|
-
expect(storage["settings"]).toMatchObject(customSettings);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should set and get values correctly", async () => {
|
|
61
|
-
const storage = new MockCookieStorage({});
|
|
62
|
-
|
|
63
|
-
await storage.set("testKey", "testValue");
|
|
64
|
-
expect(await storage.get("testKey")).toBe("testValue");
|
|
65
|
-
expect(await storage.get("nonExistentKey")).toBe(null);
|
|
66
|
-
});
|
|
67
|
-
});
|