@thunderid/nextjs 0.2.0 → 0.2.2
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/dist/{types/ThunderIDNextClient.d.ts → ThunderIDNextClient.d.ts} +2 -9
- package/dist/ThunderIDNextClient.d.ts.map +1 -0
- package/dist/ThunderIDNextClient.js +161 -0
- package/dist/ThunderIDNextClient.js.map +1 -0
- package/dist/cjs/ThunderIDNextClient.cjs +163 -0
- package/dist/cjs/ThunderIDNextClient.cjs.map +1 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs +79 -0
- package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs.map +1 -0
- package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs +61 -0
- package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs.map +1 -0
- package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs +91 -0
- package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs.map +1 -0
- package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs +34 -0
- package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs.map +1 -0
- package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs +34 -0
- package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs.map +1 -0
- package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs +37 -0
- package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs.map +1 -0
- package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs +79 -0
- package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs.map +1 -0
- package/dist/cjs/client/components/presentation/User/User.cjs +49 -0
- package/dist/cjs/client/components/presentation/User/User.cjs.map +1 -0
- package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs +114 -0
- package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs.map +1 -0
- package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs +52 -0
- package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs.map +1 -0
- package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs +34 -0
- package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs.map +1 -0
- package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs +165 -0
- package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -0
- package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs +19 -0
- package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +11 -0
- package/dist/cjs/constants/sessionConstants.cjs +55 -0
- package/dist/cjs/constants/sessionConstants.cjs.map +1 -0
- package/dist/cjs/index.cjs +35 -1037
- package/dist/cjs/server/ThunderIDProvider.cjs +114 -0
- package/dist/cjs/server/ThunderIDProvider.cjs.map +1 -0
- package/dist/cjs/server/actions/clearSession.cjs +41 -0
- package/dist/cjs/server/actions/clearSession.cjs.map +1 -0
- package/dist/cjs/server/actions/getAccessToken.cjs +27 -0
- package/dist/cjs/server/actions/getAccessToken.cjs.map +1 -0
- package/dist/cjs/server/actions/getClientOrigin.cjs +18 -0
- package/dist/cjs/server/actions/getClientOrigin.cjs.map +1 -0
- package/dist/cjs/server/actions/getSessionId.cjs +28 -0
- package/dist/cjs/server/actions/getSessionId.cjs.map +1 -0
- package/dist/cjs/server/actions/getSessionPayload.cjs +29 -0
- package/dist/cjs/server/actions/getSessionPayload.cjs.map +1 -0
- package/dist/cjs/server/actions/getUserAction.cjs +30 -0
- package/dist/cjs/server/actions/getUserAction.cjs.map +1 -0
- package/dist/cjs/server/actions/getUserProfileAction.cjs +34 -0
- package/dist/cjs/server/actions/getUserProfileAction.cjs.map +1 -0
- package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs +89 -0
- package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs.map +1 -0
- package/dist/cjs/server/actions/isSignedIn.cjs +40 -0
- package/dist/cjs/server/actions/isSignedIn.cjs.map +1 -0
- package/dist/cjs/server/actions/refreshToken.cjs +61 -0
- package/dist/cjs/server/actions/refreshToken.cjs.map +1 -0
- package/dist/cjs/server/actions/signInAction.cjs +95 -0
- package/dist/cjs/server/actions/signInAction.cjs.map +1 -0
- package/dist/cjs/server/actions/signOutAction.cjs +57 -0
- package/dist/cjs/server/actions/signOutAction.cjs.map +1 -0
- package/dist/cjs/server/actions/signUpAction.cjs +27 -0
- package/dist/cjs/server/actions/signUpAction.cjs.map +1 -0
- package/dist/cjs/server/actions/updateUserProfileAction.cjs +30 -0
- package/dist/cjs/server/actions/updateUserProfileAction.cjs.map +1 -0
- package/dist/cjs/server/getClient.cjs +19 -0
- package/dist/cjs/server/getClient.cjs.map +1 -0
- package/dist/cjs/server/index.cjs +9 -0
- package/dist/cjs/server/proxy/createRouteMatcher.cjs +36 -0
- package/dist/cjs/server/proxy/createRouteMatcher.cjs.map +1 -0
- package/dist/cjs/server/proxy/thunderIDProxy.cjs +182 -0
- package/dist/cjs/server/proxy/thunderIDProxy.cjs.map +1 -0
- package/dist/cjs/server/thunderid.cjs +27 -0
- package/dist/cjs/server/thunderid.cjs.map +1 -0
- package/dist/cjs/utils/SessionManager.cjs +150 -0
- package/dist/cjs/utils/SessionManager.cjs.map +1 -0
- package/dist/cjs/utils/decorateConfigWithNextEnv.cjs +28 -0
- package/dist/cjs/utils/decorateConfigWithNextEnv.cjs.map +1 -0
- package/dist/cjs/utils/handleRefreshToken.cjs +62 -0
- package/dist/cjs/utils/handleRefreshToken.cjs.map +1 -0
- package/dist/cjs/utils/logger.cjs +11 -0
- package/dist/cjs/utils/logger.cjs.map +1 -0
- package/dist/cjs/utils/sessionUtils.cjs +40 -0
- package/dist/cjs/utils/sessionUtils.cjs.map +1 -0
- package/dist/client/components/actions/SignInButton/SignInButton.d.ts.map +1 -0
- package/dist/client/components/actions/SignInButton/SignInButton.js +73 -0
- package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -0
- package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts.map +1 -0
- package/dist/client/components/actions/SignOutButton/SignOutButton.js +57 -0
- package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -0
- package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts.map +1 -0
- package/dist/client/components/actions/SignUpButton/SignUpButton.js +85 -0
- package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -0
- package/dist/client/components/control/Loading/Loading.d.ts.map +1 -0
- package/dist/client/components/control/SignedIn/SignedIn.d.ts.map +1 -0
- package/dist/client/components/control/SignedIn/SignedIn.js +32 -0
- package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -0
- package/dist/client/components/control/SignedOut/SignedOut.d.ts.map +1 -0
- package/dist/client/components/control/SignedOut/SignedOut.js +32 -0
- package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -0
- package/dist/{types/client → client}/components/presentation/SignIn/SignIn.d.ts +0 -38
- package/dist/client/components/presentation/SignIn/SignIn.d.ts.map +1 -0
- package/dist/client/components/presentation/SignIn/SignIn.js +33 -0
- package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -0
- package/dist/client/components/presentation/SignUp/SignUp.d.ts.map +1 -0
- package/dist/client/components/presentation/SignUp/SignUp.js +75 -0
- package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -0
- package/dist/client/components/presentation/User/User.d.ts.map +1 -0
- package/dist/client/components/presentation/User/User.js +46 -0
- package/dist/client/components/presentation/User/User.js.map +1 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +1 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.js +110 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.d.ts.map +1 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.js +49 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -0
- package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -0
- package/dist/client/contexts/ThunderID/ThunderIDContext.js +32 -0
- package/dist/client/contexts/ThunderID/ThunderIDContext.js.map +1 -0
- package/dist/{types/client → client}/contexts/ThunderID/ThunderIDProvider.d.ts +1 -8
- package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -0
- package/dist/client/contexts/ThunderID/ThunderIDProvider.js +159 -0
- package/dist/client/contexts/ThunderID/ThunderIDProvider.js.map +1 -0
- package/dist/client/contexts/ThunderID/useThunderID.d.ts.map +1 -0
- package/dist/client/contexts/ThunderID/useThunderID.js +17 -0
- package/dist/client/contexts/ThunderID/useThunderID.js.map +1 -0
- package/dist/{types/client → client}/index.d.ts +2 -10
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +13 -0
- package/dist/configs/InternalAuthAPIRoutesConfig.d.ts.map +1 -0
- package/dist/constants/sessionConstants.d.ts.map +1 -0
- package/dist/constants/sessionConstants.js +53 -0
- package/dist/constants/sessionConstants.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -981
- package/dist/models/api.d.ts.map +1 -0
- package/dist/models/config.d.ts.map +1 -0
- package/dist/server/ThunderIDProvider.d.ts.map +1 -0
- package/dist/server/ThunderIDProvider.js +111 -0
- package/dist/server/ThunderIDProvider.js.map +1 -0
- package/dist/server/actions/clearSession.d.ts.map +1 -0
- package/dist/server/actions/clearSession.js +39 -0
- package/dist/server/actions/clearSession.js.map +1 -0
- package/dist/server/actions/getAccessToken.d.ts.map +1 -0
- package/dist/{getAccessToken-DCP_zasP.js → server/actions/getAccessToken.js} +8 -5
- package/dist/server/actions/getAccessToken.js.map +1 -0
- package/dist/server/actions/getClientOrigin.d.ts.map +1 -0
- package/dist/server/actions/getClientOrigin.js +16 -0
- package/dist/server/actions/getClientOrigin.js.map +1 -0
- package/dist/server/actions/getSessionId.d.ts.map +1 -0
- package/dist/{getSessionId-Ctmvpfgp.js → server/actions/getSessionId.js} +8 -5
- package/dist/server/actions/getSessionId.js.map +1 -0
- package/dist/server/actions/getSessionPayload.d.ts.map +1 -0
- package/dist/server/actions/getSessionPayload.js +27 -0
- package/dist/server/actions/getSessionPayload.js.map +1 -0
- package/dist/server/actions/getUserAction.d.ts.map +1 -0
- package/dist/server/actions/getUserAction.js +30 -0
- package/dist/server/actions/getUserAction.js.map +1 -0
- package/dist/server/actions/getUserProfileAction.d.ts.map +1 -0
- package/dist/server/actions/getUserProfileAction.js +34 -0
- package/dist/server/actions/getUserProfileAction.js.map +1 -0
- package/dist/server/actions/handleOAuthCallbackAction.d.ts.map +1 -0
- package/dist/server/actions/handleOAuthCallbackAction.js +87 -0
- package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -0
- package/dist/server/actions/isSignedIn.d.ts.map +1 -0
- package/dist/server/actions/isSignedIn.js +40 -0
- package/dist/server/actions/isSignedIn.js.map +1 -0
- package/dist/server/actions/refreshToken.d.ts.map +1 -0
- package/dist/server/actions/refreshToken.js +58 -0
- package/dist/server/actions/refreshToken.js.map +1 -0
- package/dist/{types/server → server}/actions/signInAction.d.ts +3 -3
- package/dist/server/actions/signInAction.d.ts.map +1 -0
- package/dist/server/actions/signInAction.js +92 -0
- package/dist/server/actions/signInAction.js.map +1 -0
- package/dist/server/actions/signOutAction.d.ts.map +1 -0
- package/dist/server/actions/signOutAction.js +55 -0
- package/dist/server/actions/signOutAction.js.map +1 -0
- package/dist/{types/server/actions/getMyOrganizations.d.ts → server/actions/signUpAction.d.ts} +10 -5
- package/dist/server/actions/signUpAction.d.ts.map +1 -0
- package/dist/server/actions/signUpAction.js +27 -0
- package/dist/server/actions/signUpAction.js.map +1 -0
- package/dist/server/actions/updateUserProfileAction.d.ts.map +1 -0
- package/dist/server/actions/updateUserProfileAction.js +30 -0
- package/dist/server/actions/updateUserProfileAction.js.map +1 -0
- package/dist/server/getClient.d.ts.map +1 -0
- package/dist/server/getClient.js +19 -0
- package/dist/server/getClient.js.map +1 -0
- package/dist/{types/server → server}/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +6 -0
- package/dist/server/proxy/createRouteMatcher.d.ts.map +1 -0
- package/dist/server/proxy/createRouteMatcher.js +35 -0
- package/dist/server/proxy/createRouteMatcher.js.map +1 -0
- package/dist/{types/server/middleware/thunderIDMiddleware.d.ts → server/proxy/thunderIDProxy.d.ts} +13 -13
- package/dist/server/proxy/thunderIDProxy.d.ts.map +1 -0
- package/dist/server/proxy/thunderIDProxy.js +180 -0
- package/dist/server/proxy/thunderIDProxy.js.map +1 -0
- package/dist/server/thunderid.d.ts.map +1 -0
- package/dist/server/thunderid.js +27 -0
- package/dist/server/thunderid.js.map +1 -0
- package/dist/utils/SessionManager.d.ts.map +1 -0
- package/dist/utils/SessionManager.js +147 -0
- package/dist/utils/SessionManager.js.map +1 -0
- package/dist/utils/createRouteMatcher.d.ts.map +1 -0
- package/dist/utils/decorateConfigWithNextEnv.d.ts.map +1 -0
- package/dist/utils/decorateConfigWithNextEnv.js +27 -0
- package/dist/utils/decorateConfigWithNextEnv.js.map +1 -0
- package/dist/utils/handleRefreshToken.d.ts.map +1 -0
- package/dist/utils/handleRefreshToken.js +62 -0
- package/dist/utils/handleRefreshToken.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +9 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/sessionUtils.d.ts.map +1 -0
- package/dist/utils/sessionUtils.js +39 -0
- package/dist/utils/sessionUtils.js.map +1 -0
- package/package.json +12 -22
- package/dist/SessionManager-BPpyyzfa.js +0 -1384
- package/dist/cache-B9tFVOO5.js +0 -8047
- package/dist/cjs/SessionManager-SBxwYnwV.js +0 -1397
- package/dist/cjs/cache-0QwhuLuy.js +0 -8050
- package/dist/cjs/dynamic-rendering-W7rdgerZ.js +0 -1540
- package/dist/cjs/getAccessToken-EiHUciAb.js +0 -22
- package/dist/cjs/getSessionId-BUDHvxX2.js +0 -5
- package/dist/cjs/getSessionId-Do242Vmz.js +0 -28
- package/dist/cjs/index2.cjs +0 -8
- package/dist/cjs/middleware.cjs +0 -5151
- package/dist/cjs/segment-CPZPzHDj.js +0 -52
- package/dist/cjs/server-BAGHs6kk.js +0 -2468
- package/dist/dynamic-rendering-CkPpk5pF.js +0 -1441
- package/dist/getSessionId-pG-rZbaH.js +0 -5
- package/dist/index2.js +0 -7
- package/dist/middleware.js +0 -5152
- package/dist/segment-D3vdYYI5.js +0 -47
- package/dist/server-Bn2BrWaL.js +0 -2418
- package/dist/types/ThunderIDNextClient.d.ts.map +0 -1
- package/dist/types/client/components/actions/SignInButton/SignInButton.d.ts.map +0 -1
- package/dist/types/client/components/actions/SignOutButton/SignOutButton.d.ts.map +0 -1
- package/dist/types/client/components/actions/SignUpButton/SignUpButton.d.ts.map +0 -1
- package/dist/types/client/components/control/Loading/Loading.d.ts.map +0 -1
- package/dist/types/client/components/control/SignedIn/SignedIn.d.ts.map +0 -1
- package/dist/types/client/components/control/SignedOut/SignedOut.d.ts.map +0 -1
- package/dist/types/client/components/presentation/CreateOrganization/CreateOrganization.d.ts +0 -68
- package/dist/types/client/components/presentation/CreateOrganization/CreateOrganization.d.ts.map +0 -1
- package/dist/types/client/components/presentation/Organization/Organization.d.ts +0 -67
- package/dist/types/client/components/presentation/Organization/Organization.d.ts.map +0 -1
- package/dist/types/client/components/presentation/OrganizationList/OrganizationList.d.ts +0 -93
- package/dist/types/client/components/presentation/OrganizationList/OrganizationList.d.ts.map +0 -1
- package/dist/types/client/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +0 -120
- package/dist/types/client/components/presentation/OrganizationProfile/OrganizationProfile.d.ts.map +0 -1
- package/dist/types/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +0 -72
- package/dist/types/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts.map +0 -1
- package/dist/types/client/components/presentation/SignIn/SignIn.d.ts.map +0 -1
- package/dist/types/client/components/presentation/SignUp/SignUp.d.ts.map +0 -1
- package/dist/types/client/components/presentation/User/User.d.ts.map +0 -1
- package/dist/types/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +0 -1
- package/dist/types/client/components/presentation/UserProfile/UserProfile.d.ts.map +0 -1
- package/dist/types/client/contexts/ThunderID/ThunderIDContext.d.ts.map +0 -1
- package/dist/types/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +0 -1
- package/dist/types/client/contexts/ThunderID/useThunderID.d.ts.map +0 -1
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/configs/InternalAuthAPIRoutesConfig.d.ts.map +0 -1
- package/dist/types/constants/sessionConstants.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/middleware.d.ts +0 -35
- package/dist/types/middleware.d.ts.map +0 -1
- package/dist/types/models/api.d.ts.map +0 -1
- package/dist/types/models/config.d.ts.map +0 -1
- package/dist/types/server/ThunderIDProvider.d.ts.map +0 -1
- package/dist/types/server/actions/clearSession.d.ts.map +0 -1
- package/dist/types/server/actions/createOrganization.d.ts +0 -24
- package/dist/types/server/actions/createOrganization.d.ts.map +0 -1
- package/dist/types/server/actions/getAccessToken.d.ts.map +0 -1
- package/dist/types/server/actions/getAllOrganizations.d.ts +0 -24
- package/dist/types/server/actions/getAllOrganizations.d.ts.map +0 -1
- package/dist/types/server/actions/getBrandingPreference.d.ts +0 -24
- package/dist/types/server/actions/getBrandingPreference.d.ts.map +0 -1
- package/dist/types/server/actions/getClientOrigin.d.ts.map +0 -1
- package/dist/types/server/actions/getCurrentOrganizationAction.d.ts +0 -31
- package/dist/types/server/actions/getCurrentOrganizationAction.d.ts.map +0 -1
- package/dist/types/server/actions/getMyOrganizations.d.ts.map +0 -1
- package/dist/types/server/actions/getOrganizationAction.d.ts +0 -31
- package/dist/types/server/actions/getOrganizationAction.d.ts.map +0 -1
- package/dist/types/server/actions/getSessionId.d.ts.map +0 -1
- package/dist/types/server/actions/getSessionPayload.d.ts.map +0 -1
- package/dist/types/server/actions/getUserAction.d.ts.map +0 -1
- package/dist/types/server/actions/getUserProfileAction.d.ts.map +0 -1
- package/dist/types/server/actions/handleOAuthCallbackAction.d.ts.map +0 -1
- package/dist/types/server/actions/isSignedIn.d.ts.map +0 -1
- package/dist/types/server/actions/refreshToken.d.ts.map +0 -1
- package/dist/types/server/actions/signInAction.d.ts.map +0 -1
- package/dist/types/server/actions/signOutAction.d.ts.map +0 -1
- package/dist/types/server/actions/signUpAction.d.ts +0 -36
- package/dist/types/server/actions/signUpAction.d.ts.map +0 -1
- package/dist/types/server/actions/switchOrganization.d.ts +0 -24
- package/dist/types/server/actions/switchOrganization.d.ts.map +0 -1
- package/dist/types/server/actions/updateUserProfileAction.d.ts.map +0 -1
- package/dist/types/server/getClient.d.ts.map +0 -1
- package/dist/types/server/index.d.ts.map +0 -1
- package/dist/types/server/middleware/createRouteMatcher.d.ts.map +0 -1
- package/dist/types/server/middleware/thunderIDMiddleware.d.ts.map +0 -1
- package/dist/types/server/thunderid.d.ts.map +0 -1
- package/dist/types/utils/SessionManager.d.ts.map +0 -1
- package/dist/types/utils/createRouteMatcher.d.ts.map +0 -1
- package/dist/types/utils/decorateConfigWithNextEnv.d.ts.map +0 -1
- package/dist/types/utils/handleRefreshToken.d.ts.map +0 -1
- package/dist/types/utils/logger.d.ts.map +0 -1
- package/dist/types/utils/sessionUtils.d.ts.map +0 -1
- /package/dist/{types/client → client}/components/actions/SignInButton/SignInButton.d.ts +0 -0
- /package/dist/{types/client → client}/components/actions/SignOutButton/SignOutButton.d.ts +0 -0
- /package/dist/{types/client → client}/components/actions/SignUpButton/SignUpButton.d.ts +0 -0
- /package/dist/{types/client → client}/components/control/Loading/Loading.d.ts +0 -0
- /package/dist/{types/client → client}/components/control/SignedIn/SignedIn.d.ts +0 -0
- /package/dist/{types/client → client}/components/control/SignedOut/SignedOut.d.ts +0 -0
- /package/dist/{types/client → client}/components/presentation/SignUp/SignUp.d.ts +0 -0
- /package/dist/{types/client → client}/components/presentation/User/User.d.ts +0 -0
- /package/dist/{types/client → client}/components/presentation/UserDropdown/UserDropdown.d.ts +0 -0
- /package/dist/{types/client → client}/components/presentation/UserProfile/UserProfile.d.ts +0 -0
- /package/dist/{types/client → client}/contexts/ThunderID/ThunderIDContext.d.ts +0 -0
- /package/dist/{types/client → client}/contexts/ThunderID/useThunderID.d.ts +0 -0
- /package/dist/{types/configs → configs}/InternalAuthAPIRoutesConfig.d.ts +0 -0
- /package/dist/{types/constants → constants}/sessionConstants.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
- /package/dist/{types/models → models}/api.d.ts +0 -0
- /package/dist/{types/models → models}/config.d.ts +0 -0
- /package/dist/{types/server → server}/ThunderIDProvider.d.ts +0 -0
- /package/dist/{types/server → server}/actions/clearSession.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getAccessToken.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getClientOrigin.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getSessionId.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getSessionPayload.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getUserAction.d.ts +0 -0
- /package/dist/{types/server → server}/actions/getUserProfileAction.d.ts +0 -0
- /package/dist/{types/server → server}/actions/handleOAuthCallbackAction.d.ts +0 -0
- /package/dist/{types/server → server}/actions/isSignedIn.d.ts +0 -0
- /package/dist/{types/server → server}/actions/refreshToken.d.ts +0 -0
- /package/dist/{types/server → server}/actions/signOutAction.d.ts +0 -0
- /package/dist/{types/server → server}/actions/updateUserProfileAction.d.ts +0 -0
- /package/dist/{types/server → server}/getClient.d.ts +0 -0
- /package/dist/{types/server/middleware → server/proxy}/createRouteMatcher.d.ts +0 -0
- /package/dist/{types/server → server}/thunderid.d.ts +0 -0
- /package/dist/{types/utils → utils}/SessionManager.d.ts +0 -0
- /package/dist/{types/utils → utils}/createRouteMatcher.d.ts +0 -0
- /package/dist/{types/utils → utils}/decorateConfigWithNextEnv.d.ts +0 -0
- /package/dist/{types/utils → utils}/handleRefreshToken.d.ts +0 -0
- /package/dist/{types/utils → utils}/logger.d.ts +0 -0
- /package/dist/{types/utils → utils}/sessionUtils.d.ts +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_sessionConstants = require('../constants/sessionConstants.cjs');
|
|
3
|
+
let __thunderid_node = require("@thunderid/node");
|
|
4
|
+
__thunderid_node = require_rolldown_runtime.__toESM(__thunderid_node);
|
|
5
|
+
let jose = require("jose");
|
|
6
|
+
jose = require_rolldown_runtime.__toESM(jose);
|
|
7
|
+
|
|
8
|
+
//#region src/utils/SessionManager.ts
|
|
9
|
+
/**
|
|
10
|
+
* Session management utility class for JWT-based session cookies
|
|
11
|
+
*/
|
|
12
|
+
var SessionManager = class {
|
|
13
|
+
/**
|
|
14
|
+
* Get the signing secret from environment variable
|
|
15
|
+
* Throws error in production if not set
|
|
16
|
+
*/
|
|
17
|
+
static getSecret() {
|
|
18
|
+
const secret = process.env["THUNDERID_SECRET"];
|
|
19
|
+
if (!secret) {
|
|
20
|
+
if (process.env["NODE_ENV"] === "production") throw new __thunderid_node.ThunderIDRuntimeError("THUNDERID_SECRET environment variable is required in production", "session-secret-required", "nextjs", "Set the THUNDERID_SECRET environment variable with a secure random string");
|
|
21
|
+
console.warn("Using default secret for development. Set THUNDERID_SECRET for production!");
|
|
22
|
+
return new TextEncoder().encode("development-secret-not-for-production");
|
|
23
|
+
}
|
|
24
|
+
return new TextEncoder().encode(secret);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a temporary session cookie for login initiation
|
|
28
|
+
*/
|
|
29
|
+
static async createTempSession(sessionId) {
|
|
30
|
+
const secret = this.getSecret();
|
|
31
|
+
return await new jose.SignJWT({
|
|
32
|
+
sessionId,
|
|
33
|
+
type: "temp"
|
|
34
|
+
}).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime("15m").sign(secret);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the session cookie expiry time in seconds.
|
|
38
|
+
*
|
|
39
|
+
* Resolution order (first defined value wins):
|
|
40
|
+
* 1. `configuredExpiry` — value from `ThunderIDNodeConfig.sessionCookie?.expiryTime`
|
|
41
|
+
* 2. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME` environment variable
|
|
42
|
+
* 3. `DEFAULT_SESSION_COOKIE_EXPIRY_TIME` (24 hours)
|
|
43
|
+
*/
|
|
44
|
+
static resolveSessionCookieExpiry(configuredExpiry) {
|
|
45
|
+
if (configuredExpiry != null && configuredExpiry > 0) return configuredExpiry;
|
|
46
|
+
const envValue = process.env["THUNDERID_SESSION_COOKIE_EXPIRY_TIME"];
|
|
47
|
+
if (envValue) {
|
|
48
|
+
const parsed = parseInt(envValue, 10);
|
|
49
|
+
if (!Number.isNaN(parsed) && parsed > 0) return parsed;
|
|
50
|
+
}
|
|
51
|
+
return require_sessionConstants.DEFAULT_SESSION_COOKIE_EXPIRY_TIME;
|
|
52
|
+
}
|
|
53
|
+
static async createSessionToken(accessToken, userId, sessionId, scopes, accessTokenTtlSeconds, refreshToken, organizationId) {
|
|
54
|
+
const secret = this.getSecret();
|
|
55
|
+
return await new jose.SignJWT({
|
|
56
|
+
accessToken,
|
|
57
|
+
organizationId,
|
|
58
|
+
refreshToken,
|
|
59
|
+
scopes,
|
|
60
|
+
sessionId,
|
|
61
|
+
type: "session"
|
|
62
|
+
}).setProtectedHeader({ alg: "HS256" }).setSubject(userId).setIssuedAt().setExpirationTime(Math.floor(Date.now() / 1e3) + accessTokenTtlSeconds).sign(secret);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Verify and decode a session token
|
|
66
|
+
*/
|
|
67
|
+
static async verifySessionToken(token) {
|
|
68
|
+
try {
|
|
69
|
+
const { payload } = await (0, jose.jwtVerify)(token, this.getSecret());
|
|
70
|
+
if (payload["type"] !== "session") throw new Error("Invalid token type");
|
|
71
|
+
return payload;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw new __thunderid_node.ThunderIDRuntimeError(`Invalid session token: ${error instanceof Error ? error.message : "Unknown error"}`, "invalid-session-token", "nextjs", "Session token verification failed");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Verify a session token for refresh. Validates the HMAC signature and the
|
|
78
|
+
* `type === 'session'` discriminant but intentionally skips the `exp` check
|
|
79
|
+
* so an expired access token can still be exchanged for a new one.
|
|
80
|
+
*
|
|
81
|
+
* Session lifetime is still bounded — the cookie's `maxAge` is set from
|
|
82
|
+
* `sessionCookieExpiryTime`, so the browser drops an over-age session regardless
|
|
83
|
+
* of the access-token exp embedded in the JWT.
|
|
84
|
+
*
|
|
85
|
+
* Never use the returned payload for authorization.
|
|
86
|
+
*/
|
|
87
|
+
static async verifySessionTokenForRefresh(token) {
|
|
88
|
+
try {
|
|
89
|
+
const { payload: rawPayload } = await (0, jose.compactVerify)(token, this.getSecret());
|
|
90
|
+
const payload = JSON.parse(new TextDecoder().decode(rawPayload));
|
|
91
|
+
if (payload.type !== "session") throw new Error("Invalid token type");
|
|
92
|
+
return payload;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new __thunderid_node.ThunderIDRuntimeError(`Invalid session token: ${error instanceof Error ? error.message : "Unknown error"}`, "invalid-session-token-for-refresh", "nextjs", "Session token signature or type check failed during refresh");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Verify and decode a temporary session token
|
|
99
|
+
*/
|
|
100
|
+
static async verifyTempSession(token) {
|
|
101
|
+
try {
|
|
102
|
+
const { payload } = await (0, jose.jwtVerify)(token, this.getSecret());
|
|
103
|
+
if (payload["type"] !== "temp") throw new Error("Invalid token type");
|
|
104
|
+
return { sessionId: payload["sessionId"] };
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw new __thunderid_node.ThunderIDRuntimeError(`Invalid temporary session token: ${error instanceof Error ? error.message : "Unknown error"}`, "invalid-temp-session-token", "nextjs", "Temporary session token verification failed");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get session cookie options
|
|
111
|
+
*/
|
|
112
|
+
static getSessionCookieOptions(maxAge) {
|
|
113
|
+
return {
|
|
114
|
+
httpOnly: true,
|
|
115
|
+
maxAge,
|
|
116
|
+
path: "/",
|
|
117
|
+
sameSite: "lax",
|
|
118
|
+
secure: process.env["NODE_ENV"] === "production"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get temporary session cookie options
|
|
123
|
+
*/
|
|
124
|
+
static getTempSessionCookieOptions() {
|
|
125
|
+
return {
|
|
126
|
+
httpOnly: true,
|
|
127
|
+
maxAge: 900,
|
|
128
|
+
path: "/",
|
|
129
|
+
sameSite: "lax",
|
|
130
|
+
secure: process.env["NODE_ENV"] === "production"
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get session cookie name
|
|
135
|
+
*/
|
|
136
|
+
static getSessionCookieName() {
|
|
137
|
+
return __thunderid_node.CookieConfig.SESSION_COOKIE_NAME;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get temporary session cookie name
|
|
141
|
+
*/
|
|
142
|
+
static getTempSessionCookieName() {
|
|
143
|
+
return __thunderid_node.CookieConfig.TEMP_SESSION_COOKIE_NAME;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var SessionManager_default = SessionManager;
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
exports.default = SessionManager_default;
|
|
150
|
+
//# sourceMappingURL=SessionManager.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionManager.cjs","names":["secret: string | undefined","ThunderIDRuntimeError","secret: Uint8Array","SignJWT","envValue: string | undefined","parsed: number","DEFAULT_SESSION_COOKIE_EXPIRY_TIME","payload: SessionTokenPayload","CookieConfig"],"sources":["../../../src/utils/SessionManager.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {ThunderIDRuntimeError, CookieConfig} from '@thunderid/node';\nimport {SignJWT, jwtVerify, compactVerify, JWTPayload} from 'jose';\nimport {DEFAULT_SESSION_COOKIE_EXPIRY_TIME} from '../constants/sessionConstants';\n\n/**\n * Session token payload interface\n */\nexport interface SessionTokenPayload extends JWTPayload {\n /** Expiration timestamp — doubles as the access token expiry (JWT exp == access token exp) */\n exp: number;\n /** Issued at timestamp */\n iat: number;\n /** Organization ID if applicable */\n organizationId?: string;\n /** The refresh token; empty string if not provided by the auth server */\n refreshToken: string;\n /** OAuth scopes */\n scopes: string[];\n /** Session ID */\n sessionId: string;\n /** User ID */\n sub: string;\n /** Token type discriminant — must be 'session' for access-session JWTs */\n type: 'session';\n}\n\n/**\n * Session management utility class for JWT-based session cookies\n */\nclass SessionManager {\n /**\n * Get the signing secret from environment variable\n * Throws error in production if not set\n */\n private static getSecret(): Uint8Array {\n const secret: string | undefined = process.env['THUNDERID_SECRET'];\n\n if (!secret) {\n if (process.env['NODE_ENV'] === 'production') {\n throw new ThunderIDRuntimeError(\n 'THUNDERID_SECRET environment variable is required in production',\n 'session-secret-required',\n 'nextjs',\n 'Set the THUNDERID_SECRET environment variable with a secure random string',\n );\n }\n // Use a default secret for development (not secure)\n // eslint-disable-next-line no-console\n console.warn('Using default secret for development. Set THUNDERID_SECRET for production!');\n return new TextEncoder().encode('development-secret-not-for-production');\n }\n\n return new TextEncoder().encode(secret);\n }\n\n /**\n * Create a temporary session cookie for login initiation\n */\n static async createTempSession(sessionId: string): Promise<string> {\n const secret: Uint8Array = this.getSecret();\n\n const jwt: string = await new SignJWT({\n sessionId,\n type: 'temp',\n })\n .setProtectedHeader({alg: 'HS256'})\n .setIssuedAt()\n .setExpirationTime('15m')\n .sign(secret);\n\n return jwt;\n }\n\n /**\n * Resolve the session cookie expiry time in seconds.\n *\n * Resolution order (first defined value wins):\n * 1. `configuredExpiry` — value from `ThunderIDNodeConfig.sessionCookie?.expiryTime`\n * 2. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME` environment variable\n * 3. `DEFAULT_SESSION_COOKIE_EXPIRY_TIME` (24 hours)\n */\n static resolveSessionCookieExpiry(configuredExpiry?: number): number {\n if (configuredExpiry != null && configuredExpiry > 0) {\n return configuredExpiry;\n }\n\n const envValue: string | undefined = process.env['THUNDERID_SESSION_COOKIE_EXPIRY_TIME'];\n\n if (envValue) {\n const parsed: number = parseInt(envValue, 10);\n\n if (!Number.isNaN(parsed) && parsed > 0) {\n return parsed;\n }\n }\n\n return DEFAULT_SESSION_COOKIE_EXPIRY_TIME;\n }\n\n static async createSessionToken(\n accessToken: string,\n userId: string,\n sessionId: string,\n scopes: string,\n accessTokenTtlSeconds: number,\n refreshToken: string,\n organizationId?: string,\n ): Promise<string> {\n const secret: Uint8Array = this.getSecret();\n\n const jwt: string = await new SignJWT({\n accessToken,\n organizationId,\n refreshToken,\n scopes,\n sessionId,\n type: 'session',\n } as Omit<SessionTokenPayload, 'sub' | 'iat' | 'exp'>)\n .setProtectedHeader({alg: 'HS256'})\n .setSubject(userId)\n .setIssuedAt()\n .setExpirationTime(Math.floor(Date.now() / 1000) + accessTokenTtlSeconds)\n .sign(secret);\n\n return jwt;\n }\n\n /**\n * Verify and decode a session token\n */\n static async verifySessionToken(token: string): Promise<SessionTokenPayload> {\n try {\n const secret: Uint8Array = this.getSecret();\n const {payload} = await jwtVerify(token, secret);\n\n if (payload['type'] !== 'session') {\n throw new Error('Invalid token type');\n }\n\n return payload as SessionTokenPayload;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Invalid session token: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'invalid-session-token',\n 'nextjs',\n 'Session token verification failed',\n );\n }\n }\n\n /**\n * Verify a session token for refresh. Validates the HMAC signature and the\n * `type === 'session'` discriminant but intentionally skips the `exp` check\n * so an expired access token can still be exchanged for a new one.\n *\n * Session lifetime is still bounded — the cookie's `maxAge` is set from\n * `sessionCookieExpiryTime`, so the browser drops an over-age session regardless\n * of the access-token exp embedded in the JWT.\n *\n * Never use the returned payload for authorization.\n */\n static async verifySessionTokenForRefresh(token: string): Promise<SessionTokenPayload> {\n try {\n const secret: Uint8Array = this.getSecret();\n const {payload: rawPayload} = await compactVerify(token, secret);\n const payload: SessionTokenPayload = JSON.parse(new TextDecoder().decode(rawPayload)) as SessionTokenPayload;\n\n if (payload.type !== 'session') {\n throw new Error('Invalid token type');\n }\n\n return payload;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Invalid session token: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'invalid-session-token-for-refresh',\n 'nextjs',\n 'Session token signature or type check failed during refresh',\n );\n }\n }\n\n /**\n * Verify and decode a temporary session token\n */\n static async verifyTempSession(token: string): Promise<{sessionId: string}> {\n try {\n const secret: Uint8Array = this.getSecret();\n const {payload} = await jwtVerify(token, secret);\n\n if (payload['type'] !== 'temp') {\n throw new Error('Invalid token type');\n }\n\n return {sessionId: payload['sessionId'] as string};\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Invalid temporary session token: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'invalid-temp-session-token',\n 'nextjs',\n 'Temporary session token verification failed',\n );\n }\n }\n\n /**\n * Get session cookie options\n */\n static getSessionCookieOptions(maxAge: number): {\n httpOnly: boolean;\n maxAge: number;\n path: string;\n sameSite: 'lax';\n secure: boolean;\n } {\n return {\n httpOnly: true,\n maxAge,\n path: '/',\n sameSite: 'lax' as const,\n secure: process.env['NODE_ENV'] === 'production',\n };\n }\n\n /**\n * Get temporary session cookie options\n */\n static getTempSessionCookieOptions(): {\n httpOnly: boolean;\n maxAge: number;\n path: string;\n sameSite: 'lax';\n secure: boolean;\n } {\n return {\n httpOnly: true,\n maxAge: 15 * 60,\n path: '/',\n sameSite: 'lax' as const,\n secure: process.env['NODE_ENV'] === 'production',\n };\n }\n\n /**\n * Get session cookie name\n */\n static getSessionCookieName(): string {\n return CookieConfig.SESSION_COOKIE_NAME;\n }\n\n /**\n * Get temporary session cookie name\n */\n static getTempSessionCookieName(): string {\n return CookieConfig.TEMP_SESSION_COOKIE_NAME;\n }\n}\n\nexport default SessionManager;\n"],"mappings":";;;;;;;;;;;AA+CA,IAAM,iBAAN,MAAqB;;;;;CAKnB,OAAe,YAAwB;EACrC,MAAMA,SAA6B,QAAQ,IAAI;AAE/C,MAAI,CAAC,QAAQ;AACX,OAAI,QAAQ,IAAI,gBAAgB,aAC9B,OAAM,IAAIC,uCACR,mEACA,2BACA,UACA,4EACD;AAIH,WAAQ,KAAK,6EAA6E;AAC1F,UAAO,IAAI,aAAa,CAAC,OAAO,wCAAwC;;AAG1E,SAAO,IAAI,aAAa,CAAC,OAAO,OAAO;;;;;CAMzC,aAAa,kBAAkB,WAAoC;EACjE,MAAMC,SAAqB,KAAK,WAAW;AAW3C,SAToB,MAAM,IAAIC,aAAQ;GACpC;GACA,MAAM;GACP,CAAC,CACC,mBAAmB,EAAC,KAAK,SAAQ,CAAC,CAClC,aAAa,CACb,kBAAkB,MAAM,CACxB,KAAK,OAAO;;;;;;;;;;CAajB,OAAO,2BAA2B,kBAAmC;AACnE,MAAI,oBAAoB,QAAQ,mBAAmB,EACjD,QAAO;EAGT,MAAMC,WAA+B,QAAQ,IAAI;AAEjD,MAAI,UAAU;GACZ,MAAMC,SAAiB,SAAS,UAAU,GAAG;AAE7C,OAAI,CAAC,OAAO,MAAM,OAAO,IAAI,SAAS,EACpC,QAAO;;AAIX,SAAOC;;CAGT,aAAa,mBACX,aACA,QACA,WACA,QACA,uBACA,cACA,gBACiB;EACjB,MAAMJ,SAAqB,KAAK,WAAW;AAgB3C,SAdoB,MAAM,IAAIC,aAAQ;GACpC;GACA;GACA;GACA;GACA;GACA,MAAM;GACP,CAAqD,CACnD,mBAAmB,EAAC,KAAK,SAAQ,CAAC,CAClC,WAAW,OAAO,CAClB,aAAa,CACb,kBAAkB,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK,GAAG,sBAAsB,CACxE,KAAK,OAAO;;;;;CAQjB,aAAa,mBAAmB,OAA6C;AAC3E,MAAI;GAEF,MAAM,EAAC,YAAW,0BAAgB,OADP,KAAK,WAAW,CACK;AAEhD,OAAI,QAAQ,YAAY,UACtB,OAAM,IAAI,MAAM,qBAAqB;AAGvC,UAAO;WACA,OAAO;AACd,SAAM,IAAIF,uCACR,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,mBACnE,yBACA,UACA,oCACD;;;;;;;;;;;;;;CAeL,aAAa,6BAA6B,OAA6C;AACrF,MAAI;GAEF,MAAM,EAAC,SAAS,eAAc,8BAAoB,OADvB,KAAK,WAAW,CACqB;GAChE,MAAMM,UAA+B,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,WAAW,CAAC;AAErF,OAAI,QAAQ,SAAS,UACnB,OAAM,IAAI,MAAM,qBAAqB;AAGvC,UAAO;WACA,OAAO;AACd,SAAM,IAAIN,uCACR,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,mBACnE,qCACA,UACA,8DACD;;;;;;CAOL,aAAa,kBAAkB,OAA6C;AAC1E,MAAI;GAEF,MAAM,EAAC,YAAW,0BAAgB,OADP,KAAK,WAAW,CACK;AAEhD,OAAI,QAAQ,YAAY,OACtB,OAAM,IAAI,MAAM,qBAAqB;AAGvC,UAAO,EAAC,WAAW,QAAQ,cAAuB;WAC3C,OAAO;AACd,SAAM,IAAIA,uCACR,oCAAoC,iBAAiB,QAAQ,MAAM,UAAU,mBAC7E,8BACA,UACA,8CACD;;;;;;CAOL,OAAO,wBAAwB,QAM7B;AACA,SAAO;GACL,UAAU;GACV;GACA,MAAM;GACN,UAAU;GACV,QAAQ,QAAQ,IAAI,gBAAgB;GACrC;;;;;CAMH,OAAO,8BAML;AACA,SAAO;GACL,UAAU;GACV,QAAQ;GACR,MAAM;GACN,UAAU;GACV,QAAQ,QAAQ,IAAI,gBAAgB;GACrC;;;;;CAMH,OAAO,uBAA+B;AACpC,SAAOO,8BAAa;;;;;CAMtB,OAAO,2BAAmC;AACxC,SAAOA,8BAAa;;;AAIxB,6BAAe"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/decorateConfigWithNextEnv.ts
|
|
3
|
+
const decorateConfigWithNextEnv = (config) => {
|
|
4
|
+
const { organizationHandle, scopes, applicationId, baseUrl, clientId, clientSecret, signInUrl, signUpUrl, afterSignInUrl, afterSignOutUrl,...rest } = config;
|
|
5
|
+
const envExpiryTime = process.env["THUNDERID_SESSION_COOKIE_EXPIRY_TIME"] ? parseInt(process.env["THUNDERID_SESSION_COOKIE_EXPIRY_TIME"], 10) : void 0;
|
|
6
|
+
return {
|
|
7
|
+
...rest,
|
|
8
|
+
afterSignInUrl: afterSignInUrl || process.env["NEXT_PUBLIC_THUNDERID_AFTER_SIGN_IN_URL"],
|
|
9
|
+
afterSignOutUrl: afterSignOutUrl || process.env["NEXT_PUBLIC_THUNDERID_AFTER_SIGN_OUT_URL"],
|
|
10
|
+
applicationId: applicationId || process.env["NEXT_PUBLIC_THUNDERID_APPLICATION_ID"],
|
|
11
|
+
baseUrl: baseUrl || process.env["NEXT_PUBLIC_THUNDERID_BASE_URL"],
|
|
12
|
+
clientId: clientId || process.env["NEXT_PUBLIC_THUNDERID_CLIENT_ID"],
|
|
13
|
+
clientSecret: clientSecret || process.env["THUNDERID_CLIENT_SECRET"],
|
|
14
|
+
organizationHandle: organizationHandle || process.env["NEXT_PUBLIC_THUNDERID_ORGANIZATION_HANDLE"],
|
|
15
|
+
scopes: scopes || process.env["NEXT_PUBLIC_THUNDERID_SCOPES"],
|
|
16
|
+
sessionCookie: {
|
|
17
|
+
...rest.sessionCookie,
|
|
18
|
+
expiryTime: rest.sessionCookie?.expiryTime || envExpiryTime
|
|
19
|
+
},
|
|
20
|
+
signInUrl: signInUrl || process.env["NEXT_PUBLIC_THUNDERID_SIGN_IN_URL"],
|
|
21
|
+
signUpUrl: signUpUrl || process.env["NEXT_PUBLIC_THUNDERID_SIGN_UP_URL"]
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var decorateConfigWithNextEnv_default = decorateConfigWithNextEnv;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.default = decorateConfigWithNextEnv_default;
|
|
28
|
+
//# sourceMappingURL=decorateConfigWithNextEnv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorateConfigWithNextEnv.cjs","names":[],"sources":["../../../src/utils/decorateConfigWithNextEnv.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {ThunderIDNextConfig} from '../models/config';\n\nconst decorateConfigWithNextEnv = (config: ThunderIDNextConfig): ThunderIDNextConfig => {\n const {\n organizationHandle,\n scopes,\n applicationId,\n baseUrl,\n clientId,\n clientSecret,\n signInUrl,\n signUpUrl,\n afterSignInUrl,\n afterSignOutUrl,\n ...rest\n } = config;\n\n const envExpiryTime = process.env['THUNDERID_SESSION_COOKIE_EXPIRY_TIME']\n ? parseInt(process.env['THUNDERID_SESSION_COOKIE_EXPIRY_TIME'], 10)\n : undefined;\n\n return {\n ...rest,\n afterSignInUrl: afterSignInUrl || process.env['NEXT_PUBLIC_THUNDERID_AFTER_SIGN_IN_URL']!,\n afterSignOutUrl: afterSignOutUrl || process.env['NEXT_PUBLIC_THUNDERID_AFTER_SIGN_OUT_URL']!,\n applicationId: applicationId || process.env['NEXT_PUBLIC_THUNDERID_APPLICATION_ID']!,\n baseUrl: baseUrl || process.env['NEXT_PUBLIC_THUNDERID_BASE_URL']!,\n clientId: clientId || process.env['NEXT_PUBLIC_THUNDERID_CLIENT_ID']!,\n clientSecret: clientSecret || process.env['THUNDERID_CLIENT_SECRET']!,\n organizationHandle: organizationHandle || process.env['NEXT_PUBLIC_THUNDERID_ORGANIZATION_HANDLE']!,\n scopes: scopes || process.env['NEXT_PUBLIC_THUNDERID_SCOPES']!,\n sessionCookie: {\n ...rest.sessionCookie,\n expiryTime: rest.sessionCookie?.expiryTime || envExpiryTime,\n },\n signInUrl: signInUrl || process.env['NEXT_PUBLIC_THUNDERID_SIGN_IN_URL']!,\n signUpUrl: signUpUrl || process.env['NEXT_PUBLIC_THUNDERID_SIGN_UP_URL']!,\n };\n};\n\nexport default decorateConfigWithNextEnv;\n"],"mappings":";;AAoBA,MAAM,6BAA6B,WAAqD;CACtF,MAAM,EACJ,oBACA,QACA,eACA,SACA,UACA,cACA,WACA,WACA,gBACA,gBACA,GAAG,SACD;CAEJ,MAAM,gBAAgB,QAAQ,IAAI,0CAC9B,SAAS,QAAQ,IAAI,yCAAyC,GAAG,GACjE;AAEJ,QAAO;EACL,GAAG;EACH,gBAAgB,kBAAkB,QAAQ,IAAI;EAC9C,iBAAiB,mBAAmB,QAAQ,IAAI;EAChD,eAAe,iBAAiB,QAAQ,IAAI;EAC5C,SAAS,WAAW,QAAQ,IAAI;EAChC,UAAU,YAAY,QAAQ,IAAI;EAClC,cAAc,gBAAgB,QAAQ,IAAI;EAC1C,oBAAoB,sBAAsB,QAAQ,IAAI;EACtD,QAAQ,UAAU,QAAQ,IAAI;EAC9B,eAAe;GACb,GAAG,KAAK;GACR,YAAY,KAAK,eAAe,cAAc;GAC/C;EACD,WAAW,aAAa,QAAQ,IAAI;EACpC,WAAW,aAAa,QAAQ,IAAI;EACrC;;AAGH,wCAAe"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const require_SessionManager = require('./SessionManager.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/handleRefreshToken.ts
|
|
4
|
+
/**
|
|
5
|
+
* Handles the OAuth refresh_token grant and builds a new session JWT string.
|
|
6
|
+
*
|
|
7
|
+
* Intentionally decoupled from cookie APIs so it can be called from both the Edge
|
|
8
|
+
* Runtime (Next.js middleware) and the Node.js Runtime (server actions).
|
|
9
|
+
* Cookie persistence is the caller's responsibility.
|
|
10
|
+
*/
|
|
11
|
+
const handleRefreshToken = async (sessionPayload, config) => {
|
|
12
|
+
const { baseUrl, clientId, clientSecret, sessionCookie } = config;
|
|
13
|
+
const { refreshToken: storedRefreshToken, sessionId, sub, scopes, organizationId } = sessionPayload;
|
|
14
|
+
if (!storedRefreshToken) throw new Error("No refresh token found in session payload.");
|
|
15
|
+
const tokenEndpoint = `${baseUrl}/oauth2/token`;
|
|
16
|
+
const body = new URLSearchParams({
|
|
17
|
+
client_id: clientId ?? "",
|
|
18
|
+
client_secret: clientSecret ?? "",
|
|
19
|
+
grant_type: "refresh_token",
|
|
20
|
+
refresh_token: storedRefreshToken
|
|
21
|
+
});
|
|
22
|
+
let response;
|
|
23
|
+
try {
|
|
24
|
+
response = await fetch(tokenEndpoint, {
|
|
25
|
+
body: body.toString(),
|
|
26
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
27
|
+
method: "POST"
|
|
28
|
+
});
|
|
29
|
+
} catch (fetchError) {
|
|
30
|
+
throw new Error(`Token refresh network error: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`);
|
|
31
|
+
}
|
|
32
|
+
if (!response.ok) throw new Error(`Token endpoint rejected refresh (HTTP ${response.status}).`);
|
|
33
|
+
let tokenData;
|
|
34
|
+
try {
|
|
35
|
+
tokenData = await response.json();
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error("Failed to parse token endpoint response as JSON.");
|
|
38
|
+
}
|
|
39
|
+
const newAccessToken = tokenData["access_token"];
|
|
40
|
+
const expiresIn = tokenData["expires_in"];
|
|
41
|
+
const newRefreshToken = tokenData["refresh_token"] ?? storedRefreshToken;
|
|
42
|
+
const newScopes = tokenData["scope"] ?? (Array.isArray(scopes) ? scopes.join(" ") : scopes ?? "");
|
|
43
|
+
const resolvedSessionCookieExpiry = require_SessionManager.default.resolveSessionCookieExpiry(sessionCookie?.expiryTime);
|
|
44
|
+
return {
|
|
45
|
+
newSessionToken: await require_SessionManager.default.createSessionToken(newAccessToken, sub, sessionId, newScopes, expiresIn, newRefreshToken, organizationId),
|
|
46
|
+
sessionCookieExpiryTime: resolvedSessionCookieExpiry,
|
|
47
|
+
tokenResponse: {
|
|
48
|
+
accessToken: newAccessToken,
|
|
49
|
+
createdAt: Math.floor(Date.now() / 1e3),
|
|
50
|
+
expiresIn: String(expiresIn),
|
|
51
|
+
idToken: tokenData["id_token"] ?? "",
|
|
52
|
+
refreshToken: newRefreshToken,
|
|
53
|
+
scope: newScopes,
|
|
54
|
+
tokenType: tokenData["token_type"] ?? "Bearer"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var handleRefreshToken_default = handleRefreshToken;
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.default = handleRefreshToken_default;
|
|
62
|
+
//# sourceMappingURL=handleRefreshToken.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleRefreshToken.cjs","names":["body: URLSearchParams","response: Response","tokenData: Record<string, unknown>","newAccessToken: string","expiresIn: number","newRefreshToken: string","newScopes: string","resolvedSessionCookieExpiry: number","SessionManager"],"sources":["../../../src/utils/handleRefreshToken.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport type {TokenResponse, SessionCookieConfig} from '@thunderid/node';\nimport SessionManager, {SessionTokenPayload} from './SessionManager';\n\n/**\n * Config required to call the token endpoint.\n */\nexport interface HandleRefreshTokenConfig {\n baseUrl: string;\n clientId: string;\n clientSecret: string;\n sessionCookie?: SessionCookieConfig;\n}\n\n/**\n * Result returned by handleRefreshToken.\n * Callers are responsible for persisting newSessionToken in the appropriate cookie context.\n */\nexport interface HandleRefreshTokenResult {\n newSessionToken: string;\n sessionCookieExpiryTime: number;\n tokenResponse: TokenResponse;\n}\n\n/**\n * Handles the OAuth refresh_token grant and builds a new session JWT string.\n *\n * Intentionally decoupled from cookie APIs so it can be called from both the Edge\n * Runtime (Next.js middleware) and the Node.js Runtime (server actions).\n * Cookie persistence is the caller's responsibility.\n */\nconst handleRefreshToken = async (\n sessionPayload: SessionTokenPayload,\n config: HandleRefreshTokenConfig,\n): Promise<HandleRefreshTokenResult> => {\n const {baseUrl, clientId, clientSecret, sessionCookie} = config;\n const {refreshToken: storedRefreshToken, sessionId, sub, scopes, organizationId} = sessionPayload;\n\n if (!storedRefreshToken) {\n throw new Error('No refresh token found in session payload.');\n }\n\n const tokenEndpoint = `${baseUrl}/oauth2/token`;\n const body: URLSearchParams = new URLSearchParams({\n client_id: clientId ?? '',\n client_secret: clientSecret ?? '',\n grant_type: 'refresh_token',\n refresh_token: storedRefreshToken,\n });\n\n let response: Response;\n\n try {\n response = await fetch(tokenEndpoint, {\n body: body.toString(),\n headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n method: 'POST',\n });\n } catch (fetchError) {\n throw new Error(\n `Token refresh network error: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`,\n );\n }\n\n if (!response.ok) {\n throw new Error(`Token endpoint rejected refresh (HTTP ${response.status}).`);\n }\n\n let tokenData: Record<string, unknown>;\n\n try {\n tokenData = (await response.json()) as Record<string, unknown>;\n } catch {\n throw new Error('Failed to parse token endpoint response as JSON.');\n }\n\n const newAccessToken: string = tokenData['access_token'] as string;\n const expiresIn: number = tokenData['expires_in'] as number;\n // Use the rotated refresh token if the server provided one; otherwise keep the existing one.\n const newRefreshToken: string = (tokenData['refresh_token'] as string | undefined) ?? storedRefreshToken;\n const newScopes: string =\n (tokenData['scope'] as string | undefined) ??\n (Array.isArray(scopes) ? scopes.join(' ') : ((scopes as string) ?? ''));\n\n const resolvedSessionCookieExpiry: number = SessionManager.resolveSessionCookieExpiry(sessionCookie?.expiryTime);\n\n const newSessionToken: string = await SessionManager.createSessionToken(\n newAccessToken,\n sub,\n sessionId,\n newScopes,\n expiresIn,\n newRefreshToken,\n organizationId,\n );\n\n return {\n newSessionToken,\n sessionCookieExpiryTime: resolvedSessionCookieExpiry,\n tokenResponse: {\n accessToken: newAccessToken,\n createdAt: Math.floor(Date.now() / 1000),\n expiresIn: String(expiresIn),\n idToken: (tokenData['id_token'] as string | undefined) ?? '',\n refreshToken: newRefreshToken,\n scope: newScopes,\n tokenType: (tokenData['token_type'] as string | undefined) ?? 'Bearer',\n },\n };\n};\n\nexport default handleRefreshToken;\n"],"mappings":";;;;;;;;;;AAgDA,MAAM,qBAAqB,OACzB,gBACA,WACsC;CACtC,MAAM,EAAC,SAAS,UAAU,cAAc,kBAAiB;CACzD,MAAM,EAAC,cAAc,oBAAoB,WAAW,KAAK,QAAQ,mBAAkB;AAEnF,KAAI,CAAC,mBACH,OAAM,IAAI,MAAM,6CAA6C;CAG/D,MAAM,gBAAgB,GAAG,QAAQ;CACjC,MAAMA,OAAwB,IAAI,gBAAgB;EAChD,WAAW,YAAY;EACvB,eAAe,gBAAgB;EAC/B,YAAY;EACZ,eAAe;EAChB,CAAC;CAEF,IAAIC;AAEJ,KAAI;AACF,aAAW,MAAM,MAAM,eAAe;GACpC,MAAM,KAAK,UAAU;GACrB,SAAS,EAAC,gBAAgB,qCAAoC;GAC9D,QAAQ;GACT,CAAC;UACK,YAAY;AACnB,QAAM,IAAI,MACR,gCAAgC,sBAAsB,QAAQ,WAAW,UAAU,OAAO,WAAW,GACtG;;AAGH,KAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,yCAAyC,SAAS,OAAO,IAAI;CAG/E,IAAIC;AAEJ,KAAI;AACF,cAAa,MAAM,SAAS,MAAM;SAC5B;AACN,QAAM,IAAI,MAAM,mDAAmD;;CAGrE,MAAMC,iBAAyB,UAAU;CACzC,MAAMC,YAAoB,UAAU;CAEpC,MAAMC,kBAA2B,UAAU,oBAA2C;CACtF,MAAMC,YACH,UAAU,aACV,MAAM,QAAQ,OAAO,GAAG,OAAO,KAAK,IAAI,GAAK,UAAqB;CAErE,MAAMC,8BAAsCC,+BAAe,2BAA2B,eAAe,WAAW;AAYhH,QAAO;EACL,iBAX8B,MAAMA,+BAAe,mBACnD,gBACA,KACA,WACA,WACA,WACA,iBACA,eACD;EAIC,yBAAyB;EACzB,eAAe;GACb,aAAa;GACb,WAAW,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;GACxC,WAAW,OAAO,UAAU;GAC5B,SAAU,UAAU,eAAsC;GAC1D,cAAc;GACd,OAAO;GACP,WAAY,UAAU,iBAAwC;GAC/D;EACF;;AAGH,iCAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __thunderid_node = require("@thunderid/node");
|
|
3
|
+
__thunderid_node = require_rolldown_runtime.__toESM(__thunderid_node);
|
|
4
|
+
|
|
5
|
+
//#region src/utils/logger.ts
|
|
6
|
+
const logger = (0, __thunderid_node.createLogger)({ level: "error" });
|
|
7
|
+
var logger_default = logger;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.default = logger_default;
|
|
11
|
+
//# sourceMappingURL=logger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","names":["logger: any"],"sources":["../../../src/utils/logger.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {createLogger} from '@thunderid/node';\n\nconst logger: any = createLogger({\n level: 'error',\n});\n\nexport default logger;\n"],"mappings":";;;;;AAoBA,MAAMA,4CAA2B,EAC/B,OAAO,SACR,CAAC;AAEF,qBAAe"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const require_SessionManager = require('./SessionManager.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/utils/sessionUtils.ts
|
|
4
|
+
/**
|
|
5
|
+
* Gets the session payload from the request cookies.
|
|
6
|
+
* This includes user ID, session ID, and scopes.
|
|
7
|
+
*
|
|
8
|
+
* @param request - The Next.js request object
|
|
9
|
+
* @returns The session payload if valid, undefined otherwise
|
|
10
|
+
*/
|
|
11
|
+
const getSessionFromRequest = async (request) => {
|
|
12
|
+
try {
|
|
13
|
+
const sessionToken = request.cookies.get(require_SessionManager.default.getSessionCookieName())?.value;
|
|
14
|
+
if (!sessionToken) return;
|
|
15
|
+
return await require_SessionManager.default.verifySessionToken(sessionToken);
|
|
16
|
+
} catch {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Gets the session ID from the request cookies (legacy support).
|
|
22
|
+
* First tries to get from JWT session, then falls back to legacy session ID cookie.
|
|
23
|
+
*
|
|
24
|
+
* @param request - The Next.js request object
|
|
25
|
+
* @returns The session ID if it exists, undefined otherwise
|
|
26
|
+
*/
|
|
27
|
+
const getSessionIdFromRequest = async (request) => {
|
|
28
|
+
try {
|
|
29
|
+
const sessionPayload = await getSessionFromRequest(request);
|
|
30
|
+
if (sessionPayload) return sessionPayload.sessionId;
|
|
31
|
+
return await Promise.resolve(void 0);
|
|
32
|
+
} catch {
|
|
33
|
+
return Promise.resolve(void 0);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.getSessionFromRequest = getSessionFromRequest;
|
|
39
|
+
exports.getSessionIdFromRequest = getSessionIdFromRequest;
|
|
40
|
+
//# sourceMappingURL=sessionUtils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionUtils.cjs","names":["sessionToken: string | undefined","SessionManager","sessionPayload: SessionTokenPayload | undefined"],"sources":["../../../src/utils/sessionUtils.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {NextRequest} from 'next/server';\nimport SessionManager, {SessionTokenPayload} from './SessionManager';\n\n/**\n * Checks if a request has a valid session cookie (JWT).\n * This verifies the JWT signature and expiration.\n *\n * @param request - The Next.js request object\n * @returns True if a valid session exists, false otherwise\n */\nexport const hasValidSession = async (request: NextRequest): Promise<boolean> => {\n try {\n const sessionToken: string | undefined = request.cookies.get(SessionManager.getSessionCookieName())?.value;\n if (!sessionToken) {\n return false;\n }\n\n await SessionManager.verifySessionToken(sessionToken);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Gets the session payload from the request cookies.\n * This includes user ID, session ID, and scopes.\n *\n * @param request - The Next.js request object\n * @returns The session payload if valid, undefined otherwise\n */\nexport const getSessionFromRequest = async (request: NextRequest): Promise<SessionTokenPayload | undefined> => {\n try {\n const sessionToken: string | undefined = request.cookies.get(SessionManager.getSessionCookieName())?.value;\n if (!sessionToken) {\n return undefined;\n }\n\n return await SessionManager.verifySessionToken(sessionToken);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Gets the session ID from the request cookies (legacy support).\n * First tries to get from JWT session, then falls back to legacy session ID cookie.\n *\n * @param request - The Next.js request object\n * @returns The session ID if it exists, undefined otherwise\n */\nexport const getSessionIdFromRequest = async (request: NextRequest): Promise<string | undefined> => {\n try {\n const sessionPayload: SessionTokenPayload | undefined = await getSessionFromRequest(request);\n\n if (sessionPayload) {\n return sessionPayload.sessionId;\n }\n\n return await Promise.resolve(undefined);\n } catch {\n return Promise.resolve(undefined);\n }\n};\n\n/**\n * Gets the temporary session ID from request cookies.\n *\n * @param request - The Next.js request object\n * @returns The temporary session ID if valid, undefined otherwise\n */\nexport const getTempSessionFromRequest = async (request: NextRequest): Promise<string | undefined> => {\n try {\n const tempToken: string | undefined = request.cookies.get(SessionManager.getTempSessionCookieName())?.value;\n if (!tempToken) {\n return undefined;\n }\n\n const tempSession: {sessionId: string} = await SessionManager.verifyTempSession(tempToken);\n return tempSession.sessionId;\n } catch {\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;AAiDA,MAAa,wBAAwB,OAAO,YAAmE;AAC7G,KAAI;EACF,MAAMA,eAAmC,QAAQ,QAAQ,IAAIC,+BAAe,sBAAsB,CAAC,EAAE;AACrG,MAAI,CAAC,aACH;AAGF,SAAO,MAAMA,+BAAe,mBAAmB,aAAa;SACtD;AACN;;;;;;;;;;AAWJ,MAAa,0BAA0B,OAAO,YAAsD;AAClG,KAAI;EACF,MAAMC,iBAAkD,MAAM,sBAAsB,QAAQ;AAE5F,MAAI,eACF,QAAO,eAAe;AAGxB,SAAO,MAAM,QAAQ,QAAQ,OAAU;SACjC;AACN,SAAO,QAAQ,QAAQ,OAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignInButton.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAmB,qBAAqB,EAAiB,MAAM,kBAAkB,CAAC;AAGzF,OAAO,EAAa,yBAAyB,EAAqB,aAAa,EAAuB,MAAM,OAAO,CAAC;AAGpH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG;IACtD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,YAAY,EAAE,yBAAyB,CAAC,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CA0DjG,CAAC;AAIF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import useThunderID_default from "../../../contexts/ThunderID/useThunderID.js";
|
|
5
|
+
import { ThunderIDRuntimeError } from "@thunderid/node";
|
|
6
|
+
import { BaseSignInButton, useTranslation } from "@thunderid/react";
|
|
7
|
+
import { useRouter } from "next/navigation";
|
|
8
|
+
import { forwardRef, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/client/components/actions/SignInButton/SignInButton.tsx
|
|
12
|
+
/**
|
|
13
|
+
* SignInButton component that uses server actions for authentication in Next.js.
|
|
14
|
+
*
|
|
15
|
+
* @example Using render props
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <SignInButton>
|
|
18
|
+
* {({isLoading}) => (
|
|
19
|
+
* <button type="submit" disabled={isLoading}>
|
|
20
|
+
* {isLoading ? 'Signing in...' : 'Sign In'}
|
|
21
|
+
* </button>
|
|
22
|
+
* )}
|
|
23
|
+
* </SignInButton>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Using traditional props
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <SignInButton className="custom-button">Sign In</SignInButton>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* In Next.js with server actions, the sign-in is handled via the server action.
|
|
33
|
+
* When using render props, the custom button should use `type="submit"` instead of `onClick={signIn}`.
|
|
34
|
+
* The `signIn` function in render props is provided for API consistency but should not be used directly.
|
|
35
|
+
*/
|
|
36
|
+
const SignInButton = forwardRef(({ className, style, children, preferences, onClick, signInOptions = {},...rest }, ref) => {
|
|
37
|
+
const { signIn, signInUrl } = useThunderID_default();
|
|
38
|
+
const router = useRouter();
|
|
39
|
+
const { t } = useTranslation(preferences?.i18n);
|
|
40
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
41
|
+
const handleSignIn = async () => {
|
|
42
|
+
try {
|
|
43
|
+
setIsLoading(true);
|
|
44
|
+
if (signInUrl) router.push(signInUrl);
|
|
45
|
+
else if (signIn) await signIn(signInOptions);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new ThunderIDRuntimeError(`Sign in failed: ${error instanceof Error ? error.message : String(error)}`, "SignInButton-handleSignIn-RuntimeError-001", "nextjs", "Something went wrong while trying to sign in. Please try again later.");
|
|
48
|
+
} finally {
|
|
49
|
+
setIsLoading(false);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const handleOnClick = async (e) => {
|
|
53
|
+
await handleSignIn();
|
|
54
|
+
if (onClick) onClick(e);
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ jsx(BaseSignInButton, {
|
|
57
|
+
className,
|
|
58
|
+
style,
|
|
59
|
+
ref,
|
|
60
|
+
preferences,
|
|
61
|
+
isLoading,
|
|
62
|
+
signIn: handleSignIn,
|
|
63
|
+
onClick: handleOnClick,
|
|
64
|
+
...rest,
|
|
65
|
+
children: children ?? t("elements.buttons.signin.text")
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
SignInButton.displayName = "SignInButton";
|
|
69
|
+
var SignInButton_default = SignInButton;
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { SignInButton_default as default };
|
|
73
|
+
//# sourceMappingURL=SignInButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignInButton.js","names":["SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance"],"sources":["../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\n'use client';\n\nimport {ThunderIDRuntimeError} from '@thunderid/node';\nimport {BaseSignInButton, BaseSignInButtonProps, useTranslation} from '@thunderid/react';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter} from 'next/navigation';\nimport {forwardRef, ForwardRefExoticComponent, ReactElement, Ref, RefAttributes, MouseEvent, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignInButton}\n */\nexport type SignInButtonProps = BaseSignInButtonProps & {\n /**\n * Additional parameters to pass to the `authorize` request.\n */\n signInOptions?: Record<string, any>;\n};\n\n/**\n * SignInButton component that uses server actions for authentication in Next.js.\n *\n * @example Using render props\n * ```tsx\n * <SignInButton>\n * {({isLoading}) => (\n * <button type=\"submit\" disabled={isLoading}>\n * {isLoading ? 'Signing in...' : 'Sign In'}\n * </button>\n * )}\n * </SignInButton>\n * ```\n *\n * @example Using traditional props\n * ```tsx\n * <SignInButton className=\"custom-button\">Sign In</SignInButton>\n * ```\n *\n * @remarks\n * In Next.js with server actions, the sign-in is handled via the server action.\n * When using render props, the custom button should use `type=\"submit\"` instead of `onClick={signIn}`.\n * The `signIn` function in render props is provided for API consistency but should not be used directly.\n */\nconst SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignInButtonProps\n>(\n (\n {className, style, children, preferences, onClick, signInOptions = {}, ...rest}: SignInButtonProps,\n ref: Ref<HTMLButtonElement>,\n ): ReactElement => {\n const {signIn, signInUrl} = useThunderID();\n const router: AppRouterInstance = useRouter();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleSignIn = async (): Promise<void> => {\n try {\n setIsLoading(true);\n\n // If a custom `signInUrl` is provided, use it for navigation.\n if (signInUrl) {\n router.push(signInUrl);\n } else if (signIn) {\n await signIn(signInOptions);\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(error)}`,\n 'SignInButton-handleSignIn-RuntimeError-001',\n 'nextjs',\n 'Something went wrong while trying to sign in. Please try again later.',\n );\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleOnClick = async (e: MouseEvent<HTMLButtonElement>): Promise<void> => {\n await handleSignIn();\n if (onClick) {\n onClick(e);\n }\n };\n\n return (\n <BaseSignInButton\n className={className}\n style={style}\n ref={ref}\n preferences={preferences}\n isLoading={isLoading}\n signIn={handleSignIn}\n onClick={handleOnClick}\n {...rest}\n >\n {children ?? t('elements.buttons.signin.text')}\n </BaseSignInButton>\n );\n },\n);\n\nSignInButton.displayName = 'SignInButton';\n\nexport default SignInButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAMA,eAAgG,YAKlG,EAAC,WAAW,OAAO,UAAU,aAAa,SAAS,gBAAgB,EAAE,CAAE,GAAG,QAC1E,QACiB;CACjB,MAAM,EAAC,QAAQ,cAAaC,sBAAc;CAC1C,MAAMC,SAA4B,WAAW;CAC7C,MAAM,EAAC,MAAK,eAAe,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,eAAe,YAA2B;AAC9C,MAAI;AACF,gBAAa,KAAK;AAGlB,OAAI,UACF,QAAO,KAAK,UAAU;YACb,OACT,OAAM,OAAO,cAAc;WAEtB,OAAO;AACd,SAAM,IAAI,sBACR,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACzE,8CACA,UACA,wEACD;YACO;AACR,gBAAa,MAAM;;;CAIvB,MAAM,gBAAgB,OAAO,MAAoD;AAC/E,QAAM,cAAc;AACpB,MAAI,QACF,SAAQ,EAAE;;AAId,QACE,oBAAC;EACY;EACJ;EACF;EACQ;EACF;EACX,QAAQ;EACR,SAAS;EACT,GAAI;YAEH,YAAY,EAAE,+BAA+B;GAC7B;EAGxB;AAED,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignOutButton.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAoB,sBAAsB,EAAiB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAa,yBAAyB,EAAqB,aAAa,EAAuB,MAAM,OAAO,CAAC;AAIpH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,aAAa,EAAE,yBAAyB,CAAC,kBAAkB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAqCnG,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import logger_default from "../../../../utils/logger.js";
|
|
5
|
+
import useThunderID_default from "../../../contexts/ThunderID/useThunderID.js";
|
|
6
|
+
import { BaseSignOutButton, useTranslation } from "@thunderid/react";
|
|
7
|
+
import { forwardRef, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/client/components/actions/SignOutButton/SignOutButton.tsx
|
|
11
|
+
/**
|
|
12
|
+
* SignInButton component. This button initiates the sign-in process when clicked.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { SignInButton } from '@thunderid/auth-react';
|
|
17
|
+
*
|
|
18
|
+
* const App = () => {
|
|
19
|
+
* const buttonRef = useRef<HTMLButtonElement>(null);
|
|
20
|
+
* return (
|
|
21
|
+
* <SignInButton ref={buttonRef} className="custom-class" style={{ backgroundColor: 'blue' }}>
|
|
22
|
+
* Sign In
|
|
23
|
+
* </SignInButton>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const SignOutButton = forwardRef(({ className, style, preferences, onClick, children,...rest }, ref) => {
|
|
29
|
+
const { signOut } = useThunderID_default();
|
|
30
|
+
const { t } = useTranslation(preferences?.i18n);
|
|
31
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
32
|
+
const handleOnClick = async (e) => {
|
|
33
|
+
try {
|
|
34
|
+
setIsLoading(true);
|
|
35
|
+
logger_default.debug("[SignOutButton] Initiating a sign-out from a button click");
|
|
36
|
+
await signOut();
|
|
37
|
+
if (onClick) onClick(e);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
logger_default.error("[SignOutButton] Error occurred initiating sign-out from a button click:", error);
|
|
40
|
+
} finally {
|
|
41
|
+
setIsLoading(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsx(BaseSignOutButton, {
|
|
45
|
+
ref,
|
|
46
|
+
onClick: handleOnClick,
|
|
47
|
+
isLoading,
|
|
48
|
+
preferences,
|
|
49
|
+
...rest,
|
|
50
|
+
children: children ?? t("elements.buttons.signout.text")
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
var SignOutButton_default = SignOutButton;
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { SignOutButton_default as default };
|
|
57
|
+
//# sourceMappingURL=SignOutButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignOutButton.js","names":["SignOutButton: ForwardRefExoticComponent<SignOutButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID"],"sources":["../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\n'use client';\n\nimport {BaseSignOutButton, BaseSignOutButtonProps, useTranslation} from '@thunderid/react';\nimport {forwardRef, ForwardRefExoticComponent, ReactElement, Ref, RefAttributes, useState, MouseEvent} from 'react';\nimport logger from '../../../../utils/logger';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Interface for SignInButton component props.\n */\nexport type SignOutButtonProps = BaseSignOutButtonProps;\n\n/**\n * SignInButton component. This button initiates the sign-in process when clicked.\n *\n * @example\n * ```tsx\n * import { SignInButton } from '@thunderid/auth-react';\n *\n * const App = () => {\n * const buttonRef = useRef<HTMLButtonElement>(null);\n * return (\n * <SignInButton ref={buttonRef} className=\"custom-class\" style={{ backgroundColor: 'blue' }}>\n * Sign In\n * </SignInButton>\n * );\n * }\n * ```\n */\nconst SignOutButton: ForwardRefExoticComponent<SignOutButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignOutButtonProps\n>(\n (\n {className, style, preferences, onClick, children, ...rest}: SignOutButtonProps,\n ref: Ref<HTMLButtonElement>,\n ): ReactElement => {\n const {signOut} = useThunderID();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleOnClick = async (e: MouseEvent<HTMLButtonElement>): Promise<void> => {\n try {\n setIsLoading(true);\n\n logger.debug('[SignOutButton] Initiating a sign-out from a button click');\n\n await signOut();\n\n if (onClick) {\n onClick(e);\n }\n } catch (error) {\n logger.error('[SignOutButton] Error occurred initiating sign-out from a button click:', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <BaseSignOutButton ref={ref} onClick={handleOnClick} isLoading={isLoading} preferences={preferences} {...rest}>\n {children ?? t('elements.buttons.signout.text')}\n </BaseSignOutButton>\n );\n },\n);\n\nexport default SignOutButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAMA,gBAAkG,YAKpG,EAAC,WAAW,OAAO,aAAa,SAAS,SAAU,GAAG,QACtD,QACiB;CACjB,MAAM,EAAC,YAAWC,sBAAc;CAChC,MAAM,EAAC,MAAK,eAAe,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,gBAAgB,OAAO,MAAoD;AAC/E,MAAI;AACF,gBAAa,KAAK;AAElB,kBAAO,MAAM,4DAA4D;AAEzE,SAAM,SAAS;AAEf,OAAI,QACF,SAAQ,EAAE;WAEL,OAAO;AACd,kBAAO,MAAM,2EAA2E,MAAM;YACtF;AACR,gBAAa,MAAM;;;AAIvB,QACE,oBAAC;EAAuB;EAAK,SAAS;EAA0B;EAAwB;EAAa,GAAI;YACtG,YAAY,EAAE,gCAAgC;GAC7B;EAGzB;AAED,4BAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignUpButton.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAmB,qBAAqB,EAAiB,MAAM,kBAAkB,CAAC;AAGzF,OAAO,EAAa,yBAAyB,EAAiC,aAAa,EAAW,MAAM,OAAO,CAAC;AAGpH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,QAAA,MAAM,YAAY,EAAE,yBAAyB,CAAC,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAgDhG,CAAC;AAIH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import useThunderID_default from "../../../contexts/ThunderID/useThunderID.js";
|
|
5
|
+
import { ThunderIDRuntimeError } from "@thunderid/node";
|
|
6
|
+
import { BaseSignUpButton, useTranslation } from "@thunderid/react";
|
|
7
|
+
import { useRouter } from "next/navigation";
|
|
8
|
+
import { forwardRef, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/client/components/actions/SignUpButton/SignUpButton.tsx
|
|
12
|
+
/**
|
|
13
|
+
* SignUpButton component that supports both render props and traditional props patterns.
|
|
14
|
+
* It redirects the user to the ThunderID sign-up page configured for the application.
|
|
15
|
+
*
|
|
16
|
+
* @remarks This component is only supported in browser based React applications (CSR).
|
|
17
|
+
*
|
|
18
|
+
* @example Using render props pattern
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <SignUpButton>
|
|
21
|
+
* {({ signUp, isLoading }) => (
|
|
22
|
+
* <button onClick={signUp} disabled={isLoading}>
|
|
23
|
+
* {isLoading ? 'Creating Account...' : 'Create Account'}
|
|
24
|
+
* </button>
|
|
25
|
+
* )}
|
|
26
|
+
* </SignUpButton>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Using traditional props pattern
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <SignUpButton className="custom-button">Create Account</SignUpButton>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Using component-level preferences
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <SignUpButton
|
|
37
|
+
* preferences={{
|
|
38
|
+
* i18n: {
|
|
39
|
+
* bundles: {
|
|
40
|
+
* 'en-US': {
|
|
41
|
+
* translations: {
|
|
42
|
+
* 'buttons.signUp': 'Custom Sign Up Text'
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* }}
|
|
48
|
+
* >
|
|
49
|
+
* Custom Sign Up
|
|
50
|
+
* </SignUpButton>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
const SignUpButton = forwardRef(({ children, onClick, preferences,...rest }, ref) => {
|
|
54
|
+
const { signUp, signUpUrl } = useThunderID_default();
|
|
55
|
+
const router = useRouter();
|
|
56
|
+
const { t } = useTranslation(preferences?.i18n);
|
|
57
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
58
|
+
const handleSignUp = async (e) => {
|
|
59
|
+
try {
|
|
60
|
+
setIsLoading(true);
|
|
61
|
+
if (signUpUrl) router.push(signUpUrl);
|
|
62
|
+
else if (signUp) await signUp();
|
|
63
|
+
if (onClick) onClick(e);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
throw new ThunderIDRuntimeError(`Sign up failed: ${error instanceof Error ? error.message : String(error)}`, "SignUpButton-handleSignUp-RuntimeError-001", "nextjs", "Something went wrong while trying to sign up. Please try again later.");
|
|
66
|
+
} finally {
|
|
67
|
+
setIsLoading(false);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ jsx(BaseSignUpButton, {
|
|
71
|
+
ref,
|
|
72
|
+
onClick: handleSignUp,
|
|
73
|
+
isLoading,
|
|
74
|
+
signUp: handleSignUp,
|
|
75
|
+
preferences,
|
|
76
|
+
...rest,
|
|
77
|
+
children: children ?? t("elements.buttons.signup.text")
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
SignUpButton.displayName = "SignUpButton";
|
|
81
|
+
var SignUpButton_default = SignUpButton;
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { SignUpButton_default as default };
|
|
85
|
+
//# sourceMappingURL=SignUpButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignUpButton.js","names":["SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance"],"sources":["../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\n'use client';\n\nimport {ThunderIDRuntimeError} from '@thunderid/node';\nimport {BaseSignUpButton, BaseSignUpButtonProps, useTranslation} from '@thunderid/react';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter} from 'next/navigation';\nimport {forwardRef, ForwardRefExoticComponent, MouseEvent, ReactElement, Ref, RefAttributes, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignUpButton}\n */\nexport type SignUpButtonProps = BaseSignUpButtonProps;\n\n/**\n * SignUpButton component that supports both render props and traditional props patterns.\n * It redirects the user to the ThunderID sign-up page configured for the application.\n *\n * @remarks This component is only supported in browser based React applications (CSR).\n *\n * @example Using render props pattern\n * ```tsx\n * <SignUpButton>\n * {({ signUp, isLoading }) => (\n * <button onClick={signUp} disabled={isLoading}>\n * {isLoading ? 'Creating Account...' : 'Create Account'}\n * </button>\n * )}\n * </SignUpButton>\n * ```\n *\n * @example Using traditional props pattern\n * ```tsx\n * <SignUpButton className=\"custom-button\">Create Account</SignUpButton>\n * ```\n *\n * @example Using component-level preferences\n * ```tsx\n * <SignUpButton\n * preferences={{\n * i18n: {\n * bundles: {\n * 'en-US': {\n * translations: {\n * 'buttons.signUp': 'Custom Sign Up Text'\n * }\n * }\n * }\n * }\n * }}\n * >\n * Custom Sign Up\n * </SignUpButton>\n * ```\n */\nconst SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignUpButtonProps\n>(({children, onClick, preferences, ...rest}: SignUpButtonProps, ref: Ref<HTMLButtonElement>): ReactElement => {\n const {signUp, signUpUrl} = useThunderID();\n const router: AppRouterInstance = useRouter();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleSignUp = async (e?: MouseEvent<HTMLButtonElement>): Promise<void> => {\n try {\n setIsLoading(true);\n\n // If a custom `signUpUrl` is provided, use it for navigation.\n if (signUpUrl) {\n router.push(signUpUrl);\n } else if (signUp) {\n await signUp();\n }\n\n if (onClick) {\n onClick(e!);\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign up failed: ${error instanceof Error ? error.message : String(error)}`,\n 'SignUpButton-handleSignUp-RuntimeError-001',\n 'nextjs',\n 'Something went wrong while trying to sign up. Please try again later.',\n );\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <BaseSignUpButton\n ref={ref}\n onClick={handleSignUp}\n isLoading={isLoading}\n signUp={handleSignUp}\n preferences={preferences}\n {...rest}\n >\n {children ?? t('elements.buttons.signup.text')}\n </BaseSignUpButton>\n );\n});\n\nSignUpButton.displayName = 'SignUpButton';\n\nexport default SignUpButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAMA,eAAgG,YAGnG,EAAC,UAAU,SAAS,YAAa,GAAG,QAA0B,QAA8C;CAC7G,MAAM,EAAC,QAAQ,cAAaC,sBAAc;CAC1C,MAAMC,SAA4B,WAAW;CAC7C,MAAM,EAAC,MAAK,eAAe,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CAEjD,MAAM,eAAe,OAAO,MAAqD;AAC/E,MAAI;AACF,gBAAa,KAAK;AAGlB,OAAI,UACF,QAAO,KAAK,UAAU;YACb,OACT,OAAM,QAAQ;AAGhB,OAAI,QACF,SAAQ,EAAG;WAEN,OAAO;AACd,SAAM,IAAI,sBACR,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACzE,8CACA,UACA,wEACD;YACO;AACR,gBAAa,MAAM;;;AAIvB,QACE,oBAAC;EACM;EACL,SAAS;EACE;EACX,QAAQ;EACK;EACb,GAAI;YAEH,YAAY,EAAE,+BAA+B;GAC7B;EAErB;AAEF,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Loading.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/control/Loading/Loading.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAQhD,CAAC;AAIF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignedIn.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/control/SignedIn/SignedIn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAGvD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAOlD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|