@civic/auth 0.1.3 → 0.1.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/dist/cjs/browser/storage.d.ts +3 -0
- package/dist/cjs/browser/storage.d.ts.map +1 -1
- package/dist/cjs/browser/storage.js +8 -0
- package/dist/cjs/browser/storage.js.map +1 -1
- package/dist/cjs/lib/cookies.d.ts +2 -2
- package/dist/cjs/lib/cookies.d.ts.map +1 -1
- package/dist/cjs/lib/cookies.js +7 -5
- package/dist/cjs/lib/cookies.js.map +1 -1
- package/dist/cjs/lib/postMessage.js +1 -1
- package/dist/cjs/lib/postMessage.js.map +1 -1
- package/dist/cjs/lib/windowUtil.d.ts.map +1 -1
- package/dist/cjs/lib/windowUtil.js +1 -0
- package/dist/cjs/lib/windowUtil.js.map +1 -1
- package/dist/cjs/nextjs/config.d.ts.map +1 -1
- package/dist/cjs/nextjs/config.js +12 -0
- package/dist/cjs/nextjs/config.js.map +1 -1
- package/dist/cjs/nextjs/hooks/index.d.ts +1 -1
- package/dist/cjs/nextjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/nextjs/hooks/index.js +3 -3
- package/dist/cjs/nextjs/hooks/index.js.map +1 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/cjs/nextjs/hooks/useUserCookie.js +43 -14
- package/dist/cjs/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.d.ts +5 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
- package/dist/cjs/nextjs/providers/NextAuthProvider.js +74 -35
- package/dist/cjs/nextjs/providers/NextAuthProvider.js.map +1 -1
- package/dist/cjs/reactjs/components/UserButton.js +20 -10
- package/dist/cjs/reactjs/components/UserButton.js.map +1 -1
- package/dist/cjs/reactjs/hooks/index.d.ts +0 -1
- package/dist/cjs/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/reactjs/hooks/index.js +1 -3
- package/dist/cjs/reactjs/hooks/index.js.map +1 -1
- package/dist/cjs/services/AuthenticationService.d.ts +4 -1
- package/dist/cjs/services/AuthenticationService.d.ts.map +1 -1
- package/dist/cjs/services/AuthenticationService.js +38 -7
- package/dist/cjs/services/AuthenticationService.js.map +1 -1
- package/dist/cjs/shared/components/BlockDisplay.d.ts +7 -0
- package/dist/cjs/shared/components/BlockDisplay.d.ts.map +1 -0
- package/dist/cjs/shared/components/BlockDisplay.js +31 -0
- package/dist/cjs/shared/components/BlockDisplay.js.map +1 -0
- package/dist/cjs/shared/components/CivicAuthIframe.js +17 -7
- package/dist/cjs/shared/components/CivicAuthIframe.js.map +1 -1
- package/dist/cjs/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/cjs/shared/components/CivicAuthIframeContainer.js +39 -20
- package/dist/cjs/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/cjs/shared/components/IFrameAndLoading.d.ts +7 -0
- package/dist/cjs/shared/components/IFrameAndLoading.d.ts.map +1 -0
- package/dist/cjs/shared/components/IFrameAndLoading.js +28 -0
- package/dist/cjs/shared/components/IFrameAndLoading.js.map +1 -0
- package/dist/cjs/shared/hooks/index.d.ts +5 -1
- package/dist/cjs/shared/hooks/index.d.ts.map +1 -1
- package/dist/cjs/shared/hooks/index.js +11 -3
- package/dist/cjs/shared/hooks/index.js.map +1 -1
- package/dist/cjs/shared/hooks/useCivicAuthConfig.d.ts +3 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.js +13 -0
- package/dist/cjs/shared/hooks/useCivicAuthConfig.js.map +1 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.d.ts +3 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.js +16 -0
- package/dist/cjs/shared/hooks/useClientTokenExchangeSession.js.map +1 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.d.ts +3 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.js +27 -0
- package/dist/cjs/shared/hooks/useCurrentUrl.js.map +1 -0
- package/dist/cjs/shared/hooks/useIsInIframe.d.ts +3 -0
- package/dist/cjs/shared/hooks/useIsInIframe.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useIsInIframe.js +17 -0
- package/dist/cjs/shared/hooks/useIsInIframe.js.map +1 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.d.ts +4 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.js +17 -0
- package/dist/cjs/shared/hooks/useOAuthEndpoints.js.map +1 -0
- package/dist/cjs/shared/hooks/useRefresh.d.ts +4 -0
- package/dist/cjs/shared/hooks/useRefresh.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useRefresh.js +41 -0
- package/dist/cjs/shared/hooks/useRefresh.js.map +1 -0
- package/dist/cjs/shared/hooks/useSession.d.ts +1 -1
- package/dist/cjs/shared/hooks/useSession.d.ts.map +1 -1
- package/dist/cjs/shared/hooks/useSignIn.d.ts +14 -0
- package/dist/cjs/shared/hooks/useSignIn.d.ts.map +1 -0
- package/dist/cjs/shared/hooks/useSignIn.js +74 -0
- package/dist/cjs/shared/hooks/useSignIn.js.map +1 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.d.ts +4 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.js +30 -0
- package/dist/cjs/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/cjs/shared/lib/types.d.ts +14 -1
- package/dist/cjs/shared/lib/types.d.ts.map +1 -1
- package/dist/cjs/shared/lib/types.js +2 -0
- package/dist/cjs/shared/lib/types.js.map +1 -1
- package/dist/cjs/shared/lib/util.d.ts.map +1 -1
- package/dist/cjs/shared/lib/util.js +27 -9
- package/dist/cjs/shared/lib/util.js.map +1 -1
- package/dist/cjs/shared/providers/AuthProvider.d.ts +3 -2
- package/dist/cjs/shared/providers/AuthProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/AuthProvider.js +53 -244
- package/dist/cjs/shared/providers/AuthProvider.js.map +1 -1
- package/dist/cjs/shared/providers/CivicAuthConfigContext.d.ts +16 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.d.ts.map +1 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.js +80 -0
- package/dist/cjs/shared/providers/CivicAuthConfigContext.js.map +1 -0
- package/dist/cjs/shared/providers/CivicAuthProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/CivicAuthProvider.js +23 -6
- package/dist/cjs/shared/providers/CivicAuthProvider.js.map +1 -1
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.d.ts +17 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.d.ts.map +1 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.js +183 -0
- package/dist/cjs/shared/providers/ClientTokenExchangeSessionProvider.js.map +1 -0
- package/dist/cjs/shared/providers/IframeProvider.d.ts +7 -4
- package/dist/cjs/shared/providers/IframeProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/IframeProvider.js +37 -9
- package/dist/cjs/shared/providers/IframeProvider.js.map +1 -1
- package/dist/cjs/shared/providers/SessionProvider.d.ts +10 -4
- package/dist/cjs/shared/providers/SessionProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/SessionProvider.js +32 -12
- package/dist/cjs/shared/providers/SessionProvider.js.map +1 -1
- package/dist/cjs/shared/providers/TokenProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/TokenProvider.js +29 -30
- package/dist/cjs/shared/providers/TokenProvider.js.map +1 -1
- package/dist/cjs/shared/providers/UserProvider.d.ts +4 -3
- package/dist/cjs/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/cjs/shared/providers/UserProvider.js +46 -25
- package/dist/cjs/shared/providers/UserProvider.js.map +1 -1
- package/dist/cjs/types.d.ts +1 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/esm/browser/storage.d.ts +3 -0
- package/dist/esm/browser/storage.d.ts.map +1 -1
- package/dist/esm/browser/storage.js +8 -0
- package/dist/esm/browser/storage.js.map +1 -1
- package/dist/esm/lib/cookies.d.ts +2 -2
- package/dist/esm/lib/cookies.d.ts.map +1 -1
- package/dist/esm/lib/cookies.js +7 -5
- package/dist/esm/lib/cookies.js.map +1 -1
- package/dist/esm/lib/postMessage.js +1 -1
- package/dist/esm/lib/postMessage.js.map +1 -1
- package/dist/esm/lib/windowUtil.d.ts.map +1 -1
- package/dist/esm/lib/windowUtil.js +1 -0
- package/dist/esm/lib/windowUtil.js.map +1 -1
- package/dist/esm/nextjs/config.d.ts.map +1 -1
- package/dist/esm/nextjs/config.js +12 -0
- package/dist/esm/nextjs/config.js.map +1 -1
- package/dist/esm/nextjs/hooks/index.d.ts +1 -1
- package/dist/esm/nextjs/hooks/index.d.ts.map +1 -1
- package/dist/esm/nextjs/hooks/index.js +1 -1
- package/dist/esm/nextjs/hooks/index.js.map +1 -1
- package/dist/esm/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/esm/nextjs/hooks/useUserCookie.js +45 -16
- package/dist/esm/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.d.ts +5 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.d.ts.map +1 -1
- package/dist/esm/nextjs/providers/NextAuthProvider.js +59 -30
- package/dist/esm/nextjs/providers/NextAuthProvider.js.map +1 -1
- package/dist/esm/reactjs/components/UserButton.js +3 -3
- package/dist/esm/reactjs/components/UserButton.js.map +1 -1
- package/dist/esm/reactjs/hooks/index.d.ts +0 -1
- package/dist/esm/reactjs/hooks/index.d.ts.map +1 -1
- package/dist/esm/reactjs/hooks/index.js +0 -1
- package/dist/esm/reactjs/hooks/index.js.map +1 -1
- package/dist/esm/services/AuthenticationService.d.ts +4 -1
- package/dist/esm/services/AuthenticationService.d.ts.map +1 -1
- package/dist/esm/services/AuthenticationService.js +39 -8
- package/dist/esm/services/AuthenticationService.js.map +1 -1
- package/dist/esm/shared/components/BlockDisplay.d.ts +7 -0
- package/dist/esm/shared/components/BlockDisplay.d.ts.map +1 -0
- package/dist/esm/shared/components/BlockDisplay.js +25 -0
- package/dist/esm/shared/components/BlockDisplay.js.map +1 -0
- package/dist/esm/shared/components/CivicAuthIframeContainer.d.ts.map +1 -1
- package/dist/esm/shared/components/CivicAuthIframeContainer.js +23 -14
- package/dist/esm/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/esm/shared/components/IFrameAndLoading.d.ts +7 -0
- package/dist/esm/shared/components/IFrameAndLoading.d.ts.map +1 -0
- package/dist/esm/shared/components/IFrameAndLoading.js +22 -0
- package/dist/esm/shared/components/IFrameAndLoading.js.map +1 -0
- package/dist/esm/shared/hooks/index.d.ts +5 -1
- package/dist/esm/shared/hooks/index.d.ts.map +1 -1
- package/dist/esm/shared/hooks/index.js +5 -1
- package/dist/esm/shared/hooks/index.js.map +1 -1
- package/dist/esm/shared/hooks/useCivicAuthConfig.d.ts +3 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.js +10 -0
- package/dist/esm/shared/hooks/useCivicAuthConfig.js.map +1 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.d.ts +3 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.js +13 -0
- package/dist/esm/shared/hooks/useClientTokenExchangeSession.js.map +1 -0
- package/dist/esm/shared/hooks/useCurrentUrl.d.ts +3 -0
- package/dist/esm/shared/hooks/useCurrentUrl.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useCurrentUrl.js +24 -0
- package/dist/esm/shared/hooks/useCurrentUrl.js.map +1 -0
- package/dist/esm/shared/hooks/useIsInIframe.d.ts +3 -0
- package/dist/esm/shared/hooks/useIsInIframe.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useIsInIframe.js +14 -0
- package/dist/esm/shared/hooks/useIsInIframe.js.map +1 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.d.ts +4 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.js +14 -0
- package/dist/esm/shared/hooks/useOAuthEndpoints.js.map +1 -0
- package/dist/esm/shared/hooks/useRefresh.d.ts +4 -0
- package/dist/esm/shared/hooks/useRefresh.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useRefresh.js +38 -0
- package/dist/esm/shared/hooks/useRefresh.js.map +1 -0
- package/dist/esm/shared/hooks/useSession.d.ts +1 -1
- package/dist/esm/shared/hooks/useSession.d.ts.map +1 -1
- package/dist/esm/shared/hooks/useSignIn.d.ts +14 -0
- package/dist/esm/shared/hooks/useSignIn.d.ts.map +1 -0
- package/dist/esm/shared/hooks/useSignIn.js +71 -0
- package/dist/esm/shared/hooks/useSignIn.js.map +1 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.d.ts +4 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.d.ts.map +1 -1
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.js +30 -0
- package/dist/esm/shared/lib/GenericAuthenticationRefresher.js.map +1 -1
- package/dist/esm/shared/lib/types.d.ts +14 -1
- package/dist/esm/shared/lib/types.d.ts.map +1 -1
- package/dist/esm/shared/lib/types.js +2 -0
- package/dist/esm/shared/lib/types.js.map +1 -1
- package/dist/esm/shared/lib/util.d.ts.map +1 -1
- package/dist/esm/shared/lib/util.js +10 -2
- package/dist/esm/shared/lib/util.js.map +1 -1
- package/dist/esm/shared/providers/AuthProvider.d.ts +3 -2
- package/dist/esm/shared/providers/AuthProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/AuthProvider.js +37 -238
- package/dist/esm/shared/providers/AuthProvider.js.map +1 -1
- package/dist/esm/shared/providers/CivicAuthConfigContext.d.ts +16 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.d.ts.map +1 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.js +43 -0
- package/dist/esm/shared/providers/CivicAuthConfigContext.js.map +1 -0
- package/dist/esm/shared/providers/CivicAuthProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/CivicAuthProvider.js +23 -6
- package/dist/esm/shared/providers/CivicAuthProvider.js.map +1 -1
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.d.ts +17 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.d.ts.map +1 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.js +146 -0
- package/dist/esm/shared/providers/ClientTokenExchangeSessionProvider.js.map +1 -0
- package/dist/esm/shared/providers/IframeProvider.d.ts +7 -4
- package/dist/esm/shared/providers/IframeProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/IframeProvider.js +21 -3
- package/dist/esm/shared/providers/IframeProvider.js.map +1 -1
- package/dist/esm/shared/providers/SessionProvider.d.ts +10 -4
- package/dist/esm/shared/providers/SessionProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/SessionProvider.js +15 -5
- package/dist/esm/shared/providers/SessionProvider.js.map +1 -1
- package/dist/esm/shared/providers/TokenProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/TokenProvider.js +13 -24
- package/dist/esm/shared/providers/TokenProvider.js.map +1 -1
- package/dist/esm/shared/providers/UserProvider.d.ts +4 -3
- package/dist/esm/shared/providers/UserProvider.d.ts.map +1 -1
- package/dist/esm/shared/providers/UserProvider.js +30 -19
- package/dist/esm/shared/providers/UserProvider.js.map +1 -1
- package/dist/esm/types.d.ts +1 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/useUserCookie.d.ts.map +1 -1
- package/dist/src/nextjs/hooks/useUserCookie.js +45 -16
- package/dist/src/nextjs/hooks/useUserCookie.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -1
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -10
- package/.prettierignore +0 -3
- package/.prettierrc +0 -1
- package/.turbo/turbo-build.log +0 -13
- package/.turbo/turbo-lint$colon$fix.log +0 -10
- package/.turbo/turbo-test.log +0 -1153
- package/dist/cjs/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/cjs/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/cjs/nextjs/hooks/useTokenCookie.js +0 -41
- package/dist/cjs/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/cjs/shared/hooks/useConfig.d.ts +0 -3
- package/dist/cjs/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/cjs/shared/hooks/useConfig.js +0 -16
- package/dist/cjs/shared/hooks/useConfig.js.map +0 -1
- package/dist/cjs/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/cjs/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/cjs/shared/providers/ConfigProvider.js +0 -46
- package/dist/cjs/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/esm/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/esm/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/esm/nextjs/hooks/useTokenCookie.js +0 -37
- package/dist/esm/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/esm/shared/hooks/useConfig.d.ts +0 -3
- package/dist/esm/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/esm/shared/hooks/useConfig.js +0 -13
- package/dist/esm/shared/hooks/useConfig.js.map +0 -1
- package/dist/esm/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/esm/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/esm/shared/providers/ConfigProvider.js +0 -19
- package/dist/esm/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/src/browser/storage.d.ts +0 -6
- package/dist/src/browser/storage.d.ts.map +0 -1
- package/dist/src/browser/storage.js +0 -9
- package/dist/src/browser/storage.js.map +0 -1
- package/dist/src/config.d.ts +0 -3
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -5
- package/dist/src/config.js.map +0 -1
- package/dist/src/constants.d.ts +0 -9
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -17
- package/dist/src/constants.js.map +0 -1
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/lib/cookies.d.ts +0 -7
- package/dist/src/lib/cookies.d.ts.map +0 -1
- package/dist/src/lib/cookies.js +0 -23
- package/dist/src/lib/cookies.js.map +0 -1
- package/dist/src/lib/jwt.d.ts +0 -3
- package/dist/src/lib/jwt.d.ts.map +0 -1
- package/dist/src/lib/jwt.js +0 -9
- package/dist/src/lib/jwt.js.map +0 -1
- package/dist/src/lib/logger.d.ts +0 -26
- package/dist/src/lib/logger.d.ts.map +0 -1
- package/dist/src/lib/logger.js +0 -55
- package/dist/src/lib/logger.js.map +0 -1
- package/dist/src/lib/oauth.d.ts +0 -19
- package/dist/src/lib/oauth.d.ts.map +0 -1
- package/dist/src/lib/oauth.js +0 -60
- package/dist/src/lib/oauth.js.map +0 -1
- package/dist/src/lib/postMessage.d.ts +0 -4
- package/dist/src/lib/postMessage.d.ts.map +0 -1
- package/dist/src/lib/postMessage.js +0 -15
- package/dist/src/lib/postMessage.js.map +0 -1
- package/dist/src/lib/windowUtil.d.ts +0 -4
- package/dist/src/lib/windowUtil.d.ts.map +0 -1
- package/dist/src/lib/windowUtil.js +0 -30
- package/dist/src/lib/windowUtil.js.map +0 -1
- package/dist/src/nextjs/GetUser.d.ts +0 -6
- package/dist/src/nextjs/GetUser.d.ts.map +0 -1
- package/dist/src/nextjs/GetUser.js +0 -18
- package/dist/src/nextjs/GetUser.js.map +0 -1
- package/dist/src/nextjs/config.d.ts +0 -178
- package/dist/src/nextjs/config.d.ts.map +0 -1
- package/dist/src/nextjs/config.js +0 -161
- package/dist/src/nextjs/config.js.map +0 -1
- package/dist/src/nextjs/cookies.d.ts +0 -30
- package/dist/src/nextjs/cookies.d.ts.map +0 -1
- package/dist/src/nextjs/cookies.js +0 -112
- package/dist/src/nextjs/cookies.js.map +0 -1
- package/dist/src/nextjs/hooks/index.d.ts +0 -2
- package/dist/src/nextjs/hooks/index.d.ts.map +0 -1
- package/dist/src/nextjs/hooks/index.js +0 -2
- package/dist/src/nextjs/hooks/index.js.map +0 -1
- package/dist/src/nextjs/hooks/useTokenCookie.d.ts +0 -3
- package/dist/src/nextjs/hooks/useTokenCookie.d.ts.map +0 -1
- package/dist/src/nextjs/hooks/useTokenCookie.js +0 -37
- package/dist/src/nextjs/hooks/useTokenCookie.js.map +0 -1
- package/dist/src/nextjs/hooks/useUserCookie.d.ts +0 -3
- package/dist/src/nextjs/index.d.ts +0 -7
- package/dist/src/nextjs/index.d.ts.map +0 -1
- package/dist/src/nextjs/index.js +0 -6
- package/dist/src/nextjs/index.js.map +0 -1
- package/dist/src/nextjs/middleware/index.d.ts +0 -2
- package/dist/src/nextjs/middleware/index.d.ts.map +0 -1
- package/dist/src/nextjs/middleware/index.js +0 -2
- package/dist/src/nextjs/middleware/index.js.map +0 -1
- package/dist/src/nextjs/middleware.d.ts +0 -59
- package/dist/src/nextjs/middleware.d.ts.map +0 -1
- package/dist/src/nextjs/middleware.js +0 -107
- package/dist/src/nextjs/middleware.js.map +0 -1
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts +0 -9
- package/dist/src/nextjs/providers/NextAuthProvider.d.ts.map +0 -1
- package/dist/src/nextjs/providers/NextAuthProvider.js +0 -50
- package/dist/src/nextjs/providers/NextAuthProvider.js.map +0 -1
- package/dist/src/nextjs/routeHandler.d.ts +0 -18
- package/dist/src/nextjs/routeHandler.d.ts.map +0 -1
- package/dist/src/nextjs/routeHandler.js +0 -212
- package/dist/src/nextjs/routeHandler.js.map +0 -1
- package/dist/src/nextjs/utils.d.ts +0 -3
- package/dist/src/nextjs/utils.d.ts.map +0 -1
- package/dist/src/nextjs/utils.js +0 -5
- package/dist/src/nextjs/utils.js.map +0 -1
- package/dist/src/reactjs/components/SignInButton.d.ts +0 -8
- package/dist/src/reactjs/components/SignInButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/SignInButton.js +0 -14
- package/dist/src/reactjs/components/SignInButton.js.map +0 -1
- package/dist/src/reactjs/components/SignOutButton.d.ts +0 -6
- package/dist/src/reactjs/components/SignOutButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/SignOutButton.js +0 -14
- package/dist/src/reactjs/components/SignOutButton.js.map +0 -1
- package/dist/src/reactjs/components/UserButton.d.ts +0 -8
- package/dist/src/reactjs/components/UserButton.d.ts.map +0 -1
- package/dist/src/reactjs/components/UserButton.js +0 -118
- package/dist/src/reactjs/components/UserButton.js.map +0 -1
- package/dist/src/reactjs/components/index.d.ts +0 -6
- package/dist/src/reactjs/components/index.d.ts.map +0 -1
- package/dist/src/reactjs/components/index.js +0 -6
- package/dist/src/reactjs/components/index.js.map +0 -1
- package/dist/src/reactjs/hooks/index.d.ts +0 -7
- package/dist/src/reactjs/hooks/index.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/index.js +0 -7
- package/dist/src/reactjs/hooks/index.js.map +0 -1
- package/dist/src/reactjs/hooks/useAuth.d.ts +0 -3
- package/dist/src/reactjs/hooks/useAuth.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/useAuth.js +0 -12
- package/dist/src/reactjs/hooks/useAuth.js.map +0 -1
- package/dist/src/reactjs/hooks/useUser.d.ts +0 -4
- package/dist/src/reactjs/hooks/useUser.d.ts.map +0 -1
- package/dist/src/reactjs/hooks/useUser.js +0 -12
- package/dist/src/reactjs/hooks/useUser.js.map +0 -1
- package/dist/src/reactjs/index.d.ts +0 -6
- package/dist/src/reactjs/index.d.ts.map +0 -1
- package/dist/src/reactjs/index.js +0 -8
- package/dist/src/reactjs/index.js.map +0 -1
- package/dist/src/reactjs/providers/index.d.ts +0 -8
- package/dist/src/reactjs/providers/index.d.ts.map +0 -1
- package/dist/src/reactjs/providers/index.js +0 -7
- package/dist/src/reactjs/providers/index.js.map +0 -1
- package/dist/src/server/ServerAuthenticationResolver.d.ts +0 -19
- package/dist/src/server/ServerAuthenticationResolver.d.ts.map +0 -1
- package/dist/src/server/ServerAuthenticationResolver.js +0 -61
- package/dist/src/server/ServerAuthenticationResolver.js.map +0 -1
- package/dist/src/server/config.d.ts +0 -9
- package/dist/src/server/config.d.ts.map +0 -1
- package/dist/src/server/config.js +0 -2
- package/dist/src/server/config.js.map +0 -1
- package/dist/src/server/index.d.ts +0 -7
- package/dist/src/server/index.d.ts.map +0 -1
- package/dist/src/server/index.js +0 -5
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/login.d.ts +0 -17
- package/dist/src/server/login.d.ts.map +0 -1
- package/dist/src/server/login.js +0 -37
- package/dist/src/server/login.js.map +0 -1
- package/dist/src/server/refresh.d.ts +0 -7
- package/dist/src/server/refresh.d.ts.map +0 -1
- package/dist/src/server/refresh.js +0 -13
- package/dist/src/server/refresh.js.map +0 -1
- package/dist/src/services/AuthenticationService.d.ts +0 -87
- package/dist/src/services/AuthenticationService.d.ts.map +0 -1
- package/dist/src/services/AuthenticationService.js +0 -212
- package/dist/src/services/AuthenticationService.js.map +0 -1
- package/dist/src/services/PKCE.d.ts +0 -20
- package/dist/src/services/PKCE.d.ts.map +0 -1
- package/dist/src/services/PKCE.js +0 -44
- package/dist/src/services/PKCE.js.map +0 -1
- package/dist/src/services/types.d.ts +0 -23
- package/dist/src/services/types.d.ts.map +0 -1
- package/dist/src/services/types.js +0 -7
- package/dist/src/services/types.js.map +0 -1
- package/dist/src/shared/components/CivicAuthIframe.d.ts +0 -8
- package/dist/src/shared/components/CivicAuthIframe.d.ts.map +0 -1
- package/dist/src/shared/components/CivicAuthIframe.js +0 -9
- package/dist/src/shared/components/CivicAuthIframe.js.map +0 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.d.ts +0 -9
- package/dist/src/shared/components/CivicAuthIframeContainer.d.ts.map +0 -1
- package/dist/src/shared/components/CivicAuthIframeContainer.js +0 -129
- package/dist/src/shared/components/CivicAuthIframeContainer.js.map +0 -1
- package/dist/src/shared/components/CloseIcon.d.ts +0 -4
- package/dist/src/shared/components/CloseIcon.d.ts.map +0 -1
- package/dist/src/shared/components/CloseIcon.js +0 -6
- package/dist/src/shared/components/CloseIcon.js.map +0 -1
- package/dist/src/shared/components/LoadingIcon.d.ts +0 -4
- package/dist/src/shared/components/LoadingIcon.d.ts.map +0 -1
- package/dist/src/shared/components/LoadingIcon.js +0 -30
- package/dist/src/shared/components/LoadingIcon.js.map +0 -1
- package/dist/src/shared/hooks/index.d.ts +0 -5
- package/dist/src/shared/hooks/index.d.ts.map +0 -1
- package/dist/src/shared/hooks/index.js +0 -5
- package/dist/src/shared/hooks/index.js.map +0 -1
- package/dist/src/shared/hooks/useAuth.d.ts +0 -3
- package/dist/src/shared/hooks/useAuth.d.ts.map +0 -1
- package/dist/src/shared/hooks/useAuth.js +0 -12
- package/dist/src/shared/hooks/useAuth.js.map +0 -1
- package/dist/src/shared/hooks/useConfig.d.ts +0 -3
- package/dist/src/shared/hooks/useConfig.d.ts.map +0 -1
- package/dist/src/shared/hooks/useConfig.js +0 -13
- package/dist/src/shared/hooks/useConfig.js.map +0 -1
- package/dist/src/shared/hooks/useIframe.d.ts +0 -3
- package/dist/src/shared/hooks/useIframe.d.ts.map +0 -1
- package/dist/src/shared/hooks/useIframe.js +0 -13
- package/dist/src/shared/hooks/useIframe.js.map +0 -1
- package/dist/src/shared/hooks/useSession.d.ts +0 -3
- package/dist/src/shared/hooks/useSession.d.ts.map +0 -1
- package/dist/src/shared/hooks/useSession.js +0 -13
- package/dist/src/shared/hooks/useSession.js.map +0 -1
- package/dist/src/shared/hooks/useToken.d.ts +0 -3
- package/dist/src/shared/hooks/useToken.d.ts.map +0 -1
- package/dist/src/shared/hooks/useToken.js +0 -12
- package/dist/src/shared/hooks/useToken.js.map +0 -1
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts +0 -16
- package/dist/src/shared/lib/GenericAuthenticationRefresher.d.ts.map +0 -1
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js +0 -43
- package/dist/src/shared/lib/GenericAuthenticationRefresher.js.map +0 -1
- package/dist/src/shared/lib/UserSession.d.ts +0 -12
- package/dist/src/shared/lib/UserSession.d.ts.map +0 -1
- package/dist/src/shared/lib/UserSession.js +0 -20
- package/dist/src/shared/lib/UserSession.js.map +0 -1
- package/dist/src/shared/lib/session.d.ts +0 -3
- package/dist/src/shared/lib/session.d.ts.map +0 -1
- package/dist/src/shared/lib/session.js +0 -10
- package/dist/src/shared/lib/session.js.map +0 -1
- package/dist/src/shared/lib/storage.d.ts +0 -25
- package/dist/src/shared/lib/storage.d.ts.map +0 -1
- package/dist/src/shared/lib/storage.js +0 -17
- package/dist/src/shared/lib/storage.js.map +0 -1
- package/dist/src/shared/lib/types.d.ts +0 -22
- package/dist/src/shared/lib/types.d.ts.map +0 -1
- package/dist/src/shared/lib/types.js +0 -16
- package/dist/src/shared/lib/types.js.map +0 -1
- package/dist/src/shared/lib/util.d.ts +0 -33
- package/dist/src/shared/lib/util.d.ts.map +0 -1
- package/dist/src/shared/lib/util.js +0 -124
- package/dist/src/shared/lib/util.js.map +0 -1
- package/dist/src/shared/providers/AuthContext.d.ts +0 -10
- package/dist/src/shared/providers/AuthContext.d.ts.map +0 -1
- package/dist/src/shared/providers/AuthContext.js +0 -3
- package/dist/src/shared/providers/AuthContext.js.map +0 -1
- package/dist/src/shared/providers/AuthProvider.d.ts +0 -20
- package/dist/src/shared/providers/AuthProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/AuthProvider.js +0 -264
- package/dist/src/shared/providers/AuthProvider.js.map +0 -1
- package/dist/src/shared/providers/CivicAuthProvider.d.ts +0 -6
- package/dist/src/shared/providers/CivicAuthProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/CivicAuthProvider.js +0 -15
- package/dist/src/shared/providers/CivicAuthProvider.js.map +0 -1
- package/dist/src/shared/providers/ConfigProvider.d.ts +0 -21
- package/dist/src/shared/providers/ConfigProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/ConfigProvider.js +0 -19
- package/dist/src/shared/providers/ConfigProvider.js.map +0 -1
- package/dist/src/shared/providers/IframeProvider.d.ts +0 -16
- package/dist/src/shared/providers/IframeProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/IframeProvider.js +0 -11
- package/dist/src/shared/providers/IframeProvider.js.map +0 -1
- package/dist/src/shared/providers/SessionProvider.d.ts +0 -13
- package/dist/src/shared/providers/SessionProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/SessionProvider.js +0 -13
- package/dist/src/shared/providers/SessionProvider.js.map +0 -1
- package/dist/src/shared/providers/TokenProvider.d.ts +0 -18
- package/dist/src/shared/providers/TokenProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/TokenProvider.js +0 -53
- package/dist/src/shared/providers/TokenProvider.js.map +0 -1
- package/dist/src/shared/providers/UserProvider.d.ts +0 -18
- package/dist/src/shared/providers/UserProvider.d.ts.map +0 -1
- package/dist/src/shared/providers/UserProvider.js +0 -38
- package/dist/src/shared/providers/UserProvider.js.map +0 -1
- package/dist/src/types.d.ts +0 -146
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -15
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -43
- package/dist/src/utils.js.map +0 -1
- package/dist/test/integration/sdk.test.d.ts +0 -2
- package/dist/test/integration/sdk.test.d.ts.map +0 -1
- package/dist/test/integration/sdk.test.js +0 -183
- package/dist/test/integration/sdk.test.js.map +0 -1
- package/dist/test/support/fixtures.d.ts +0 -26
- package/dist/test/support/fixtures.d.ts.map +0 -1
- package/dist/test/support/fixtures.js +0 -55
- package/dist/test/support/fixtures.js.map +0 -1
- package/dist/test/support/tokens.json +0 -26
- package/dist/test/unit/lib/oauth.test.d.ts +0 -2
- package/dist/test/unit/lib/oauth.test.d.ts.map +0 -1
- package/dist/test/unit/lib/oauth.test.js +0 -55
- package/dist/test/unit/lib/oauth.test.js.map +0 -1
- package/dist/test/unit/logger.test.d.ts +0 -2
- package/dist/test/unit/logger.test.d.ts.map +0 -1
- package/dist/test/unit/logger.test.js +0 -141
- package/dist/test/unit/logger.test.js.map +0 -1
- package/dist/test/unit/nextjs/NextAuthProvider.test.d.ts +0 -2
- package/dist/test/unit/nextjs/NextAuthProvider.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/NextAuthProvider.test.js +0 -29
- package/dist/test/unit/nextjs/NextAuthProvider.test.js.map +0 -1
- package/dist/test/unit/nextjs/config.test.d.ts +0 -2
- package/dist/test/unit/nextjs/config.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/config.test.js +0 -189
- package/dist/test/unit/nextjs/config.test.js.map +0 -1
- package/dist/test/unit/nextjs/getUser.test.d.ts +0 -2
- package/dist/test/unit/nextjs/getUser.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/getUser.test.js +0 -36
- package/dist/test/unit/nextjs/getUser.test.js.map +0 -1
- package/dist/test/unit/nextjs/middleware.test.d.ts +0 -2
- package/dist/test/unit/nextjs/middleware.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/middleware.test.js +0 -113
- package/dist/test/unit/nextjs/middleware.test.js.map +0 -1
- package/dist/test/unit/nextjs/utils.test.d.ts +0 -2
- package/dist/test/unit/nextjs/utils.test.d.ts.map +0 -1
- package/dist/test/unit/nextjs/utils.test.js +0 -13
- package/dist/test/unit/nextjs/utils.test.js.map +0 -1
- package/dist/test/unit/publicApi/apiSnapshot.test.d.ts +0 -2
- package/dist/test/unit/publicApi/apiSnapshot.test.d.ts.map +0 -1
- package/dist/test/unit/publicApi/apiSnapshot.test.js +0 -10
- package/dist/test/unit/publicApi/apiSnapshot.test.js.map +0 -1
- package/dist/test/unit/react/components/SignInButton.test.d.ts +0 -2
- package/dist/test/unit/react/components/SignInButton.test.d.ts.map +0 -1
- package/dist/test/unit/react/components/SignInButton.test.js +0 -31
- package/dist/test/unit/react/components/SignInButton.test.js.map +0 -1
- package/dist/test/unit/react/components/SignOutButton.test.d.ts +0 -2
- package/dist/test/unit/react/components/SignOutButton.test.d.ts.map +0 -1
- package/dist/test/unit/react/components/SignOutButton.test.js +0 -30
- package/dist/test/unit/react/components/SignOutButton.test.js.map +0 -1
- package/dist/test/unit/server/login.test.d.ts +0 -2
- package/dist/test/unit/server/login.test.d.ts.map +0 -1
- package/dist/test/unit/server/login.test.js +0 -127
- package/dist/test/unit/server/login.test.js.map +0 -1
- package/dist/test/unit/server/session.test.d.ts +0 -2
- package/dist/test/unit/server/session.test.d.ts.map +0 -1
- package/dist/test/unit/server/session.test.js +0 -41
- package/dist/test/unit/server/session.test.js.map +0 -1
- package/dist/test/unit/services/AuthenticationService.test.d.ts +0 -2
- package/dist/test/unit/services/AuthenticationService.test.d.ts.map +0 -1
- package/dist/test/unit/services/AuthenticationService.test.js +0 -104
- package/dist/test/unit/services/AuthenticationService.test.js.map +0 -1
- package/dist/test/unit/services/ServerAuthenticationResolver.test.d.ts +0 -2
- package/dist/test/unit/services/ServerAuthenticationResolver.test.d.ts.map +0 -1
- package/dist/test/unit/services/ServerAuthenticationResolver.test.js +0 -74
- package/dist/test/unit/services/ServerAuthenticationResolver.test.js.map +0 -1
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.d.ts +0 -2
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.d.ts.map +0 -1
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.js +0 -61
- package/dist/test/unit/shared/GenericAuthenticationRefresher.test.js.map +0 -1
- package/dist/test/unit/shared/UserSession.test.d.ts +0 -2
- package/dist/test/unit/shared/UserSession.test.d.ts.map +0 -1
- package/dist/test/unit/shared/UserSession.test.js +0 -37
- package/dist/test/unit/shared/UserSession.test.js.map +0 -1
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.d.ts +0 -2
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.d.ts.map +0 -1
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.js +0 -120
- package/dist/test/unit/shared/components/CivicAuthIframeContainer.test.js.map +0 -1
- package/dist/test/unit/shared/storage.test.d.ts +0 -2
- package/dist/test/unit/shared/storage.test.d.ts.map +0 -1
- package/dist/test/unit/shared/storage.test.js +0 -53
- package/dist/test/unit/shared/storage.test.js.map +0 -1
- package/dist/test/unit/utils.test.d.ts +0 -2
- package/dist/test/unit/utils.test.d.ts.map +0 -1
- package/dist/test/unit/utils.test.js +0 -40
- package/dist/test/unit/utils.test.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -40
- package/dist/vitest.config.js.map +0 -1
- package/src/browser/storage.ts +0 -11
- package/src/config.ts +0 -6
- package/src/constants.ts +0 -29
- package/src/index.ts +0 -16
- package/src/lib/cookies.ts +0 -28
- package/src/lib/jwt.ts +0 -15
- package/src/lib/logger.ts +0 -72
- package/src/lib/oauth.ts +0 -83
- package/src/lib/postMessage.ts +0 -22
- package/src/lib/windowUtil.ts +0 -29
- package/src/nextjs/GetUser.ts +0 -22
- package/src/nextjs/config.ts +0 -203
- package/src/nextjs/cookies.ts +0 -162
- package/src/nextjs/hooks/index.ts +0 -1
- package/src/nextjs/hooks/useTokenCookie.ts +0 -41
- package/src/nextjs/hooks/useUserCookie.ts +0 -41
- package/src/nextjs/index.ts +0 -20
- package/src/nextjs/middleware/index.ts +0 -1
- package/src/nextjs/middleware.ts +0 -155
- package/src/nextjs/providers/NextAuthProvider.tsx +0 -87
- package/src/nextjs/routeHandler.ts +0 -297
- package/src/nextjs/utils.ts +0 -9
- package/src/reactjs/components/SignInButton.tsx +0 -32
- package/src/reactjs/components/SignOutButton.tsx +0 -24
- package/src/reactjs/components/UserButton.tsx +0 -239
- package/src/reactjs/components/index.ts +0 -5
- package/src/reactjs/hooks/index.ts +0 -6
- package/src/reactjs/hooks/useAuth.ts +0 -15
- package/src/reactjs/hooks/useUser.ts +0 -20
- package/src/reactjs/index.ts +0 -19
- package/src/reactjs/providers/index.ts +0 -27
- package/src/server/ServerAuthenticationResolver.ts +0 -107
- package/src/server/config.ts +0 -9
- package/src/server/index.ts +0 -13
- package/src/server/login.ts +0 -59
- package/src/server/refresh.ts +0 -23
- package/src/services/AuthenticationService.ts +0 -329
- package/src/services/PKCE.ts +0 -45
- package/src/services/types.ts +0 -54
- package/src/shared/components/CivicAuthIframe.tsx +0 -26
- package/src/shared/components/CivicAuthIframeContainer.tsx +0 -195
- package/src/shared/components/CloseIcon.tsx +0 -21
- package/src/shared/components/LoadingIcon.tsx +0 -53
- package/src/shared/hooks/index.ts +0 -4
- package/src/shared/hooks/useAuth.ts +0 -15
- package/src/shared/hooks/useConfig.ts +0 -14
- package/src/shared/hooks/useIframe.ts +0 -14
- package/src/shared/hooks/useSession.ts +0 -14
- package/src/shared/hooks/useToken.ts +0 -15
- package/src/shared/lib/GenericAuthenticationRefresher.ts +0 -75
- package/src/shared/lib/UserSession.ts +0 -25
- package/src/shared/lib/session.ts +0 -11
- package/src/shared/lib/storage.ts +0 -40
- package/src/shared/lib/types.ts +0 -26
- package/src/shared/lib/util.ts +0 -212
- package/src/shared/providers/AuthContext.tsx +0 -11
- package/src/shared/providers/AuthProvider.tsx +0 -397
- package/src/shared/providers/CivicAuthProvider.tsx +0 -31
- package/src/shared/providers/ConfigProvider.tsx +0 -50
- package/src/shared/providers/IframeProvider.tsx +0 -34
- package/src/shared/providers/SessionProvider.tsx +0 -29
- package/src/shared/providers/TokenProvider.tsx +0 -78
- package/src/shared/providers/UserProvider.tsx +0 -80
- package/src/types.ts +0 -227
- package/src/utils.ts +0 -58
- package/test/integration/sdk.test.tsx +0 -266
- package/test/support/fixtures.ts +0 -56
- package/test/support/tokens.json +0 -26
- package/test/unit/lib/oauth.test.ts +0 -72
- package/test/unit/logger.test.ts +0 -175
- package/test/unit/nextjs/NextAuthProvider.test.tsx +0 -38
- package/test/unit/nextjs/config.test.ts +0 -218
- package/test/unit/nextjs/getUser.test.ts +0 -41
- package/test/unit/nextjs/middleware.test.ts +0 -138
- package/test/unit/nextjs/routeHandler.test.ts.skipped +0 -369
- package/test/unit/nextjs/utils.test.ts +0 -17
- package/test/unit/publicApi/__snapshots__/apiSnapshot.test.ts.snap +0 -17
- package/test/unit/publicApi/apiSnapshot.test.ts +0 -11
- package/test/unit/react/components/SignInButton.test.tsx +0 -50
- package/test/unit/react/components/SignOutButton.test.tsx +0 -49
- package/test/unit/server/login.test.ts +0 -181
- package/test/unit/server/session.test.ts +0 -51
- package/test/unit/services/AuthenticationService.test.ts +0 -152
- package/test/unit/services/ServerAuthenticationResolver.test.ts +0 -115
- package/test/unit/shared/GenericAuthenticationRefresher.test.ts +0 -89
- package/test/unit/shared/UserSession.test.ts +0 -42
- package/test/unit/shared/components/CivicAuthIframeContainer.test.tsx +0 -154
- package/test/unit/shared/storage.test.ts +0 -67
- package/test/unit/utils.test.ts +0 -48
- package/tsconfig.build.json +0 -9
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -7
- package/tsconfig.json +0 -42
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -41
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const LoadingIcon = () => (
|
|
4
|
-
<div id="civic-auth-loading-icon" role="status">
|
|
5
|
-
<style>
|
|
6
|
-
{`
|
|
7
|
-
@keyframes spin {
|
|
8
|
-
0% { transform: rotate(0deg); }
|
|
9
|
-
100% { transform: rotate(360deg); }
|
|
10
|
-
}
|
|
11
|
-
`}
|
|
12
|
-
</style>
|
|
13
|
-
<svg
|
|
14
|
-
aria-hidden="true"
|
|
15
|
-
style={{
|
|
16
|
-
display: "inline",
|
|
17
|
-
height: "2rem",
|
|
18
|
-
width: "2rem",
|
|
19
|
-
animation: "spin 1s linear infinite",
|
|
20
|
-
fill: "#4b5563",
|
|
21
|
-
color: "#e5e7eb",
|
|
22
|
-
}}
|
|
23
|
-
viewBox="0 0 100 101"
|
|
24
|
-
fill="none"
|
|
25
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
26
|
-
>
|
|
27
|
-
<path
|
|
28
|
-
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
29
|
-
fill="currentColor"
|
|
30
|
-
/>
|
|
31
|
-
<path
|
|
32
|
-
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
33
|
-
fill="currentFill"
|
|
34
|
-
/>
|
|
35
|
-
</svg>
|
|
36
|
-
<span
|
|
37
|
-
style={{
|
|
38
|
-
position: "absolute",
|
|
39
|
-
width: "1px",
|
|
40
|
-
height: "1px",
|
|
41
|
-
padding: 0,
|
|
42
|
-
margin: "-1px",
|
|
43
|
-
overflow: "hidden",
|
|
44
|
-
clip: "rect(0, 0, 0, 0)",
|
|
45
|
-
border: 0,
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
Loading...
|
|
49
|
-
</span>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
export { LoadingIcon };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { AuthContext } from "@/shared/providers/AuthContext.js";
|
|
4
|
-
|
|
5
|
-
const useAuth = () => {
|
|
6
|
-
const context = useContext(AuthContext);
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useAuth must be used within an AuthProvider");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return context;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { useAuth };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { ConfigContext } from "@/shared/providers/ConfigProvider.js";
|
|
4
|
-
|
|
5
|
-
// TokenProvider will use this internal context to access Config
|
|
6
|
-
const useConfig = () => {
|
|
7
|
-
const context = useContext(ConfigContext);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useConfig must be used within an ConfigProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useConfig };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { IframeContext } from "@/shared/providers/IframeProvider.js";
|
|
4
|
-
|
|
5
|
-
// TokenProvider will use this internal context to access Iframe
|
|
6
|
-
const useIframe = () => {
|
|
7
|
-
const context = useContext(IframeContext);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useIframe must be used within an IframeProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useIframe };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { SessionContext } from "@/shared/providers/SessionProvider.js";
|
|
4
|
-
|
|
5
|
-
// TokenProvider will use this internal context to access session
|
|
6
|
-
const useSession = () => {
|
|
7
|
-
const context = useContext(SessionContext);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useSession must be used within an SessionProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useSession };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { TokenContext } from "@/shared/providers/TokenProvider.js";
|
|
4
|
-
|
|
5
|
-
const useToken = () => {
|
|
6
|
-
const context = useContext(TokenContext);
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useToken must be used within a TokenProvider");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return context;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { useToken };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { AuthenticationRefresher } from "@/services/types.js";
|
|
2
|
-
import type { AuthStorage, Endpoints, OIDCTokenResponseBody } from "@/types.js";
|
|
3
|
-
import {
|
|
4
|
-
getEndpointsWithOverrides,
|
|
5
|
-
retrieveTokens,
|
|
6
|
-
storeTokens,
|
|
7
|
-
} from "@/shared/lib/util.js";
|
|
8
|
-
import type { AuthConfig } from "@/server/config.js";
|
|
9
|
-
import { OAuth2Client } from "oslo/oauth2";
|
|
10
|
-
import { DEFAULT_AUTH_SERVER } from "@/constants.js";
|
|
11
|
-
|
|
12
|
-
export class GenericAuthenticationRefresher implements AuthenticationRefresher {
|
|
13
|
-
private oauth2client: OAuth2Client | undefined;
|
|
14
|
-
private endpoints: Endpoints | undefined;
|
|
15
|
-
|
|
16
|
-
private constructor(
|
|
17
|
-
private authConfig: AuthConfig,
|
|
18
|
-
private storage: AuthStorage,
|
|
19
|
-
private endpointOverrides?: Partial<Endpoints>,
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
get oauthServer(): string {
|
|
23
|
-
return this.authConfig.oauthServer || DEFAULT_AUTH_SERVER;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async init(): Promise<this> {
|
|
27
|
-
// resolve oauth config
|
|
28
|
-
this.endpoints = await getEndpointsWithOverrides(
|
|
29
|
-
this.oauthServer,
|
|
30
|
-
this.endpointOverrides,
|
|
31
|
-
);
|
|
32
|
-
this.oauth2client = new OAuth2Client(
|
|
33
|
-
this.authConfig.clientId,
|
|
34
|
-
this.endpoints.auth,
|
|
35
|
-
this.endpoints.token,
|
|
36
|
-
{
|
|
37
|
-
redirectURI: this.authConfig.redirectUrl,
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static async build(
|
|
45
|
-
authConfig: AuthConfig,
|
|
46
|
-
storage: AuthStorage,
|
|
47
|
-
endpointOverrides?: Partial<Endpoints>,
|
|
48
|
-
): Promise<GenericAuthenticationRefresher> {
|
|
49
|
-
const refresher = new GenericAuthenticationRefresher(
|
|
50
|
-
authConfig,
|
|
51
|
-
storage,
|
|
52
|
-
endpointOverrides,
|
|
53
|
-
);
|
|
54
|
-
await refresher.init();
|
|
55
|
-
|
|
56
|
-
return refresher;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async refreshTokens() {
|
|
60
|
-
if (!this.oauth2client) await this.init();
|
|
61
|
-
|
|
62
|
-
const tokens = await retrieveTokens(this.storage);
|
|
63
|
-
if (!tokens?.refresh_token) throw new Error("No refresh token available");
|
|
64
|
-
|
|
65
|
-
const oauth2Client = this.oauth2client!;
|
|
66
|
-
const refreshedTokens =
|
|
67
|
-
await oauth2Client.refreshAccessToken<OIDCTokenResponseBody>(
|
|
68
|
-
tokens.refresh_token,
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
await storeTokens(this.storage, refreshedTokens);
|
|
72
|
-
|
|
73
|
-
return tokens;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { AuthStorage, ForwardedTokensJWT, User } from "@/types.js";
|
|
2
|
-
import { UserStorage } from "@/shared/lib/types.js";
|
|
3
|
-
import { convertForwardedTokenFormat } from "@/lib/jwt.js";
|
|
4
|
-
|
|
5
|
-
export interface UserSession {
|
|
6
|
-
get(): Promise<User | null>;
|
|
7
|
-
set(user: User): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class GenericUserSession implements UserSession {
|
|
11
|
-
constructor(readonly storage: AuthStorage) {}
|
|
12
|
-
|
|
13
|
-
async get(): Promise<User | null> {
|
|
14
|
-
const user = await this.storage.get(UserStorage.USER);
|
|
15
|
-
return user ? JSON.parse(user) : null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async set(user: User | null): Promise<void> {
|
|
19
|
-
const forwardedTokens = user?.forwardedTokens
|
|
20
|
-
? convertForwardedTokenFormat(user?.forwardedTokens as ForwardedTokensJWT)
|
|
21
|
-
: null;
|
|
22
|
-
const value = user ? JSON.stringify({ ...user, forwardedTokens }) : "";
|
|
23
|
-
await this.storage.set(UserStorage.USER, value);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { retrieveTokens } from "@/shared/lib/util.js";
|
|
2
|
-
import { parseJWT } from "oslo/jwt";
|
|
3
|
-
import type { AuthStorage, User } from "@/types.js";
|
|
4
|
-
|
|
5
|
-
export async function getUser(storage: AuthStorage): Promise<User | null> {
|
|
6
|
-
const tokens = await retrieveTokens(storage);
|
|
7
|
-
if (!tokens) return null;
|
|
8
|
-
|
|
9
|
-
// Assumes all information is in the ID token
|
|
10
|
-
return (parseJWT(tokens.id_token)?.payload as User) ?? null;
|
|
11
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { AuthStorage, SessionData, UnknownObject, User } from "@/types.js";
|
|
2
|
-
|
|
3
|
-
type SameSiteOption = "strict" | "lax" | "none";
|
|
4
|
-
|
|
5
|
-
export interface SessionStorage {
|
|
6
|
-
get(): SessionData;
|
|
7
|
-
getUser(): User<UnknownObject> | null;
|
|
8
|
-
set(data: Partial<SessionData>): void;
|
|
9
|
-
setUser(data: User<UnknownObject> | null): void;
|
|
10
|
-
clear(): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type CookieStorageSettings = {
|
|
14
|
-
httpOnly: boolean;
|
|
15
|
-
secure: boolean;
|
|
16
|
-
sameSite: SameSiteOption;
|
|
17
|
-
expires: Date;
|
|
18
|
-
path: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const DEFAULT_COOKIE_DURATION = 60 * 15; // 15 minutes
|
|
22
|
-
|
|
23
|
-
export abstract class CookieStorage implements AuthStorage {
|
|
24
|
-
protected settings: CookieStorageSettings;
|
|
25
|
-
protected constructor(settings: Partial<CookieStorageSettings> = {}) {
|
|
26
|
-
this.settings = {
|
|
27
|
-
httpOnly: settings.httpOnly ?? true,
|
|
28
|
-
secure: settings.secure ?? true,
|
|
29
|
-
// the callback request comes the auth server
|
|
30
|
-
// 'lax' ensures the code_verifier cookie is sent with the request
|
|
31
|
-
sameSite: settings.sameSite ?? "lax",
|
|
32
|
-
expires:
|
|
33
|
-
settings.expires ??
|
|
34
|
-
new Date(Date.now() + 1000 * DEFAULT_COOKIE_DURATION),
|
|
35
|
-
path: settings.path ?? "/",
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
abstract get(key: string): Promise<string | null>;
|
|
39
|
-
abstract set(key: string, value: string): Promise<void>;
|
|
40
|
-
}
|
package/src/shared/lib/types.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export enum OAuthTokens {
|
|
2
|
-
ID_TOKEN = "id_token",
|
|
3
|
-
ACCESS_TOKEN = "access_token",
|
|
4
|
-
REFRESH_TOKEN = "refresh_token",
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum CodeVerifier {
|
|
8
|
-
COOKIE_NAME = "code_verifier",
|
|
9
|
-
APP_URL = "app_url",
|
|
10
|
-
}
|
|
11
|
-
export enum UserStorage {
|
|
12
|
-
USER = "user",
|
|
13
|
-
}
|
|
14
|
-
export interface CookieConfig {
|
|
15
|
-
secure?: boolean;
|
|
16
|
-
sameSite?: "strict" | "lax" | "none";
|
|
17
|
-
domain?: string;
|
|
18
|
-
path?: string;
|
|
19
|
-
maxAge?: number;
|
|
20
|
-
httpOnly?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type TokensCookieConfig = Record<
|
|
24
|
-
OAuthTokens | CodeVerifier,
|
|
25
|
-
CookieConfig
|
|
26
|
-
>;
|
package/src/shared/lib/util.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
// Utility functions shared by auth server and client integrations
|
|
2
|
-
// Typically these functions should be used inside AuthenticationInitiator and AuthenticationResolver implementations
|
|
3
|
-
import type {
|
|
4
|
-
AuthStorage,
|
|
5
|
-
Endpoints,
|
|
6
|
-
JWTPayload,
|
|
7
|
-
OIDCTokenResponseBody,
|
|
8
|
-
ParsedTokens,
|
|
9
|
-
} from "@/types.js";
|
|
10
|
-
import { OAuthTokens } from "./types.js";
|
|
11
|
-
import { OAuth2Client } from "oslo/oauth2";
|
|
12
|
-
import { getIssuerVariations, getOauthEndpoints } from "@/lib/oauth.js";
|
|
13
|
-
import * as jose from "jose";
|
|
14
|
-
import { withoutUndefined } from "@/utils.js";
|
|
15
|
-
import type { PKCEConsumer, PKCEProducer } from "@/services/types.js";
|
|
16
|
-
import { GenericUserSession } from "@/shared/lib/UserSession.js";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Given a PKCE code verifier, derive the code challenge using SHA
|
|
20
|
-
*/
|
|
21
|
-
export async function deriveCodeChallenge(
|
|
22
|
-
codeVerifier: string,
|
|
23
|
-
method: "Plain" | "S256" = "S256",
|
|
24
|
-
): Promise<string> {
|
|
25
|
-
if (method === "Plain") {
|
|
26
|
-
console.warn("Using insecure plain code challenge method");
|
|
27
|
-
return codeVerifier;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const encoder = new TextEncoder();
|
|
31
|
-
const data = encoder.encode(codeVerifier);
|
|
32
|
-
const digest = await crypto.subtle.digest("SHA-256", data);
|
|
33
|
-
return btoa(String.fromCharCode(...new Uint8Array(digest)))
|
|
34
|
-
.replace(/\+/g, "-")
|
|
35
|
-
.replace(/\//g, "_")
|
|
36
|
-
.replace(/=+$/, "");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function getEndpointsWithOverrides(
|
|
40
|
-
oauthServer: string,
|
|
41
|
-
endpointOverrides: Partial<Endpoints> = {},
|
|
42
|
-
): Promise<Endpoints> {
|
|
43
|
-
const endpoints = await getOauthEndpoints(oauthServer);
|
|
44
|
-
return {
|
|
45
|
-
...endpoints,
|
|
46
|
-
...endpointOverrides,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export async function generateOauthLoginUrl(config: {
|
|
51
|
-
clientId: string;
|
|
52
|
-
scopes: string[];
|
|
53
|
-
state: string;
|
|
54
|
-
redirectUrl: string;
|
|
55
|
-
oauthServer: string;
|
|
56
|
-
nonce?: string;
|
|
57
|
-
endpointOverrides?: Partial<Endpoints>;
|
|
58
|
-
// used to get the PKCE challenge
|
|
59
|
-
pkceConsumer: PKCEConsumer;
|
|
60
|
-
}): Promise<URL> {
|
|
61
|
-
const endpoints = await getEndpointsWithOverrides(
|
|
62
|
-
config.oauthServer,
|
|
63
|
-
config.endpointOverrides,
|
|
64
|
-
);
|
|
65
|
-
const oauth2Client = buildOauth2Client(
|
|
66
|
-
config.clientId,
|
|
67
|
-
config.redirectUrl,
|
|
68
|
-
endpoints,
|
|
69
|
-
);
|
|
70
|
-
const challenge = await config.pkceConsumer.getCodeChallenge();
|
|
71
|
-
const oAuthUrl = await oauth2Client.createAuthorizationURL({
|
|
72
|
-
state: config.state,
|
|
73
|
-
scopes: config.scopes,
|
|
74
|
-
});
|
|
75
|
-
// The OAuth2 client supports PKCE, but does not allow passing in a code challenge from some other source
|
|
76
|
-
// It only allows passing in a code verifier which it then hashes itself.
|
|
77
|
-
oAuthUrl.searchParams.append("code_challenge", challenge);
|
|
78
|
-
oAuthUrl.searchParams.append("code_challenge_method", "S256");
|
|
79
|
-
if (config.nonce) {
|
|
80
|
-
// nonce isn't supported by oslo, so we add it manually
|
|
81
|
-
oAuthUrl.searchParams.append("nonce", config.nonce);
|
|
82
|
-
}
|
|
83
|
-
// Required by the auth server for offline_access scope
|
|
84
|
-
oAuthUrl.searchParams.append("prompt", "consent");
|
|
85
|
-
|
|
86
|
-
return oAuthUrl;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export async function generateOauthLogoutUrl(config: {
|
|
90
|
-
clientId: string;
|
|
91
|
-
scopes: string[];
|
|
92
|
-
oauthServer: string;
|
|
93
|
-
endpointOverrides?: Partial<Endpoints>;
|
|
94
|
-
// used to get the PKCE challenge
|
|
95
|
-
pkceConsumer: PKCEConsumer;
|
|
96
|
-
}): Promise<URL> {
|
|
97
|
-
// TODO TECH-676: Implement logout
|
|
98
|
-
console.log("generateOauthLogoutUrl not implemented", config);
|
|
99
|
-
return new URL("http://localhost");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function buildOauth2Client(
|
|
103
|
-
clientId: string,
|
|
104
|
-
redirectUri: string,
|
|
105
|
-
endpoints: Endpoints,
|
|
106
|
-
): OAuth2Client {
|
|
107
|
-
return new OAuth2Client(clientId, endpoints.auth, endpoints.token, {
|
|
108
|
-
redirectURI: redirectUri,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export async function exchangeTokens(
|
|
113
|
-
code: string,
|
|
114
|
-
state: string,
|
|
115
|
-
pkceProducer: PKCEProducer,
|
|
116
|
-
oauth2Client: OAuth2Client,
|
|
117
|
-
oauthServer: string,
|
|
118
|
-
endpoints: Endpoints,
|
|
119
|
-
) {
|
|
120
|
-
const codeVerifier = await pkceProducer.getCodeVerifier();
|
|
121
|
-
if (!codeVerifier) throw new Error("Code verifier not found in state");
|
|
122
|
-
|
|
123
|
-
const tokens =
|
|
124
|
-
await oauth2Client.validateAuthorizationCode<OIDCTokenResponseBody>(code, {
|
|
125
|
-
codeVerifier,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Validate relevant tokens
|
|
129
|
-
try {
|
|
130
|
-
await validateOauth2Tokens(tokens, endpoints, oauth2Client, oauthServer);
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.error("tokenExchange error", { error, tokens });
|
|
133
|
-
throw new Error(
|
|
134
|
-
`OIDC tokens validation failed: ${(error as Error).message}`,
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return tokens;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export async function storeTokens(
|
|
142
|
-
storage: AuthStorage,
|
|
143
|
-
tokens: OIDCTokenResponseBody,
|
|
144
|
-
) {
|
|
145
|
-
// store tokens in storage ( TODO we should probably store them against the state to allow multiple logins )
|
|
146
|
-
await storage.set(OAuthTokens.ID_TOKEN, tokens.id_token);
|
|
147
|
-
await storage.set(OAuthTokens.ACCESS_TOKEN, tokens.access_token);
|
|
148
|
-
if (tokens.refresh_token) {
|
|
149
|
-
await storage.set(OAuthTokens.REFRESH_TOKEN, tokens.refresh_token);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export async function clearTokens(storage: AuthStorage) {
|
|
154
|
-
const clearOAuthPromises = Object.values(OAuthTokens).map((cookie) => {
|
|
155
|
-
storage.set(cookie, "");
|
|
156
|
-
});
|
|
157
|
-
await Promise.all([...clearOAuthPromises]);
|
|
158
|
-
}
|
|
159
|
-
export async function clearUser(storage: AuthStorage) {
|
|
160
|
-
const userSession = new GenericUserSession(storage);
|
|
161
|
-
await userSession.set(null);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export async function retrieveTokens(
|
|
165
|
-
storage: AuthStorage,
|
|
166
|
-
): Promise<OIDCTokenResponseBody | null> {
|
|
167
|
-
const idToken = await storage.get(OAuthTokens.ID_TOKEN);
|
|
168
|
-
const accessToken = await storage.get(OAuthTokens.ACCESS_TOKEN);
|
|
169
|
-
const refreshToken = await storage.get(OAuthTokens.REFRESH_TOKEN);
|
|
170
|
-
|
|
171
|
-
if (!idToken || !accessToken) return null;
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
id_token: idToken,
|
|
175
|
-
access_token: accessToken,
|
|
176
|
-
refresh_token: refreshToken ?? undefined,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export async function validateOauth2Tokens(
|
|
181
|
-
tokens: OIDCTokenResponseBody,
|
|
182
|
-
endpoints: Endpoints,
|
|
183
|
-
oauth2Client: OAuth2Client,
|
|
184
|
-
issuer: string,
|
|
185
|
-
): Promise<ParsedTokens> {
|
|
186
|
-
const JWKS = jose.createRemoteJWKSet(new URL(endpoints.jwks));
|
|
187
|
-
|
|
188
|
-
// validate the ID token
|
|
189
|
-
const idTokenResponse = await jose.jwtVerify<JWTPayload>(
|
|
190
|
-
tokens.id_token,
|
|
191
|
-
JWKS,
|
|
192
|
-
{
|
|
193
|
-
issuer: getIssuerVariations(issuer),
|
|
194
|
-
audience: oauth2Client.clientId,
|
|
195
|
-
},
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
// validate the access token
|
|
199
|
-
const accessTokenResponse = await jose.jwtVerify<JWTPayload>(
|
|
200
|
-
tokens.access_token,
|
|
201
|
-
JWKS,
|
|
202
|
-
{
|
|
203
|
-
issuer: getIssuerVariations(issuer),
|
|
204
|
-
},
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
return withoutUndefined({
|
|
208
|
-
id_token: idTokenResponse.payload,
|
|
209
|
-
access_token: accessTokenResponse.payload,
|
|
210
|
-
refresh_token: tokens.refresh_token,
|
|
211
|
-
});
|
|
212
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
import type { DisplayMode } from "@/types.js";
|
|
3
|
-
|
|
4
|
-
export type AuthContextType = {
|
|
5
|
-
signIn: (displayMode?: DisplayMode) => Promise<void>;
|
|
6
|
-
isAuthenticated: boolean;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
error: Error | null;
|
|
9
|
-
signOut: () => Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export const AuthContext = createContext<AuthContextType | null>(null);
|