@thunderid/nextjs 0.2.1 → 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.
Files changed (349) hide show
  1. package/dist/{types/ThunderIDNextClient.d.ts → ThunderIDNextClient.d.ts} +1 -7
  2. package/dist/ThunderIDNextClient.d.ts.map +1 -0
  3. package/dist/ThunderIDNextClient.js +161 -0
  4. package/dist/ThunderIDNextClient.js.map +1 -0
  5. package/dist/cjs/ThunderIDNextClient.cjs +163 -0
  6. package/dist/cjs/ThunderIDNextClient.cjs.map +1 -0
  7. package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
  8. package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs +79 -0
  9. package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs.map +1 -0
  10. package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs +61 -0
  11. package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs.map +1 -0
  12. package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs +91 -0
  13. package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs.map +1 -0
  14. package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs +34 -0
  15. package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs.map +1 -0
  16. package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs +34 -0
  17. package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs.map +1 -0
  18. package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs +37 -0
  19. package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs.map +1 -0
  20. package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs +79 -0
  21. package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs.map +1 -0
  22. package/dist/cjs/client/components/presentation/User/User.cjs +49 -0
  23. package/dist/cjs/client/components/presentation/User/User.cjs.map +1 -0
  24. package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs +114 -0
  25. package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs.map +1 -0
  26. package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs +52 -0
  27. package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs.map +1 -0
  28. package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs +34 -0
  29. package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs.map +1 -0
  30. package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs +165 -0
  31. package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -0
  32. package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs +19 -0
  33. package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs.map +1 -0
  34. package/dist/cjs/client/index.cjs +11 -0
  35. package/dist/cjs/constants/sessionConstants.cjs +55 -0
  36. package/dist/cjs/constants/sessionConstants.cjs.map +1 -0
  37. package/dist/cjs/index.cjs +35 -990
  38. package/dist/cjs/server/ThunderIDProvider.cjs +114 -0
  39. package/dist/cjs/server/ThunderIDProvider.cjs.map +1 -0
  40. package/dist/cjs/server/actions/clearSession.cjs +41 -0
  41. package/dist/cjs/server/actions/clearSession.cjs.map +1 -0
  42. package/dist/cjs/server/actions/getAccessToken.cjs +27 -0
  43. package/dist/cjs/server/actions/getAccessToken.cjs.map +1 -0
  44. package/dist/cjs/server/actions/getClientOrigin.cjs +18 -0
  45. package/dist/cjs/server/actions/getClientOrigin.cjs.map +1 -0
  46. package/dist/cjs/server/actions/getSessionId.cjs +28 -0
  47. package/dist/cjs/server/actions/getSessionId.cjs.map +1 -0
  48. package/dist/cjs/server/actions/getSessionPayload.cjs +29 -0
  49. package/dist/cjs/server/actions/getSessionPayload.cjs.map +1 -0
  50. package/dist/cjs/server/actions/getUserAction.cjs +30 -0
  51. package/dist/cjs/server/actions/getUserAction.cjs.map +1 -0
  52. package/dist/cjs/server/actions/getUserProfileAction.cjs +34 -0
  53. package/dist/cjs/server/actions/getUserProfileAction.cjs.map +1 -0
  54. package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs +89 -0
  55. package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs.map +1 -0
  56. package/dist/cjs/server/actions/isSignedIn.cjs +40 -0
  57. package/dist/cjs/server/actions/isSignedIn.cjs.map +1 -0
  58. package/dist/cjs/server/actions/refreshToken.cjs +61 -0
  59. package/dist/cjs/server/actions/refreshToken.cjs.map +1 -0
  60. package/dist/cjs/server/actions/signInAction.cjs +95 -0
  61. package/dist/cjs/server/actions/signInAction.cjs.map +1 -0
  62. package/dist/cjs/server/actions/signOutAction.cjs +57 -0
  63. package/dist/cjs/server/actions/signOutAction.cjs.map +1 -0
  64. package/dist/cjs/server/actions/signUpAction.cjs +27 -0
  65. package/dist/cjs/server/actions/signUpAction.cjs.map +1 -0
  66. package/dist/cjs/server/actions/updateUserProfileAction.cjs +30 -0
  67. package/dist/cjs/server/actions/updateUserProfileAction.cjs.map +1 -0
  68. package/dist/cjs/server/getClient.cjs +19 -0
  69. package/dist/cjs/server/getClient.cjs.map +1 -0
  70. package/dist/cjs/server/index.cjs +9 -0
  71. package/dist/cjs/server/proxy/createRouteMatcher.cjs +36 -0
  72. package/dist/cjs/server/proxy/createRouteMatcher.cjs.map +1 -0
  73. package/dist/cjs/server/proxy/thunderIDProxy.cjs +182 -0
  74. package/dist/cjs/server/proxy/thunderIDProxy.cjs.map +1 -0
  75. package/dist/cjs/server/thunderid.cjs +27 -0
  76. package/dist/cjs/server/thunderid.cjs.map +1 -0
  77. package/dist/cjs/utils/SessionManager.cjs +150 -0
  78. package/dist/cjs/utils/SessionManager.cjs.map +1 -0
  79. package/dist/cjs/utils/decorateConfigWithNextEnv.cjs +28 -0
  80. package/dist/cjs/utils/decorateConfigWithNextEnv.cjs.map +1 -0
  81. package/dist/cjs/utils/handleRefreshToken.cjs +62 -0
  82. package/dist/cjs/utils/handleRefreshToken.cjs.map +1 -0
  83. package/dist/cjs/utils/logger.cjs +11 -0
  84. package/dist/cjs/utils/logger.cjs.map +1 -0
  85. package/dist/cjs/utils/sessionUtils.cjs +40 -0
  86. package/dist/cjs/utils/sessionUtils.cjs.map +1 -0
  87. package/dist/client/components/actions/SignInButton/SignInButton.d.ts.map +1 -0
  88. package/dist/client/components/actions/SignInButton/SignInButton.js +73 -0
  89. package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -0
  90. package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts.map +1 -0
  91. package/dist/client/components/actions/SignOutButton/SignOutButton.js +57 -0
  92. package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -0
  93. package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts.map +1 -0
  94. package/dist/client/components/actions/SignUpButton/SignUpButton.js +85 -0
  95. package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -0
  96. package/dist/client/components/control/Loading/Loading.d.ts.map +1 -0
  97. package/dist/client/components/control/SignedIn/SignedIn.d.ts.map +1 -0
  98. package/dist/client/components/control/SignedIn/SignedIn.js +32 -0
  99. package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -0
  100. package/dist/client/components/control/SignedOut/SignedOut.d.ts.map +1 -0
  101. package/dist/client/components/control/SignedOut/SignedOut.js +32 -0
  102. package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -0
  103. package/dist/client/components/presentation/SignIn/SignIn.d.ts.map +1 -0
  104. package/dist/client/components/presentation/SignIn/SignIn.js +33 -0
  105. package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -0
  106. package/dist/client/components/presentation/SignUp/SignUp.d.ts.map +1 -0
  107. package/dist/client/components/presentation/SignUp/SignUp.js +75 -0
  108. package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -0
  109. package/dist/client/components/presentation/User/User.d.ts.map +1 -0
  110. package/dist/client/components/presentation/User/User.js +46 -0
  111. package/dist/client/components/presentation/User/User.js.map +1 -0
  112. package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +1 -0
  113. package/dist/client/components/presentation/UserDropdown/UserDropdown.js +110 -0
  114. package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -0
  115. package/dist/client/components/presentation/UserProfile/UserProfile.d.ts.map +1 -0
  116. package/dist/client/components/presentation/UserProfile/UserProfile.js +49 -0
  117. package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -0
  118. package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -0
  119. package/dist/client/contexts/ThunderID/ThunderIDContext.js +32 -0
  120. package/dist/client/contexts/ThunderID/ThunderIDContext.js.map +1 -0
  121. package/dist/{types/client → client}/contexts/ThunderID/ThunderIDProvider.d.ts +1 -8
  122. package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -0
  123. package/dist/client/contexts/ThunderID/ThunderIDProvider.js +159 -0
  124. package/dist/client/contexts/ThunderID/ThunderIDProvider.js.map +1 -0
  125. package/dist/client/contexts/ThunderID/useThunderID.d.ts.map +1 -0
  126. package/dist/client/contexts/ThunderID/useThunderID.js +17 -0
  127. package/dist/client/contexts/ThunderID/useThunderID.js.map +1 -0
  128. package/dist/{types/client → client}/index.d.ts +2 -10
  129. package/dist/client/index.d.ts.map +1 -0
  130. package/dist/client/index.js +13 -0
  131. package/dist/configs/InternalAuthAPIRoutesConfig.d.ts.map +1 -0
  132. package/dist/constants/sessionConstants.d.ts.map +1 -0
  133. package/dist/constants/sessionConstants.js +53 -0
  134. package/dist/constants/sessionConstants.js.map +1 -0
  135. package/dist/index.d.ts.map +1 -0
  136. package/dist/index.js +20 -934
  137. package/dist/models/api.d.ts.map +1 -0
  138. package/dist/models/config.d.ts.map +1 -0
  139. package/dist/server/ThunderIDProvider.d.ts.map +1 -0
  140. package/dist/server/ThunderIDProvider.js +111 -0
  141. package/dist/server/ThunderIDProvider.js.map +1 -0
  142. package/dist/server/actions/clearSession.d.ts.map +1 -0
  143. package/dist/server/actions/clearSession.js +39 -0
  144. package/dist/server/actions/clearSession.js.map +1 -0
  145. package/dist/server/actions/getAccessToken.d.ts.map +1 -0
  146. package/dist/{getAccessToken-oRxArjVC.js → server/actions/getAccessToken.js} +8 -5
  147. package/dist/server/actions/getAccessToken.js.map +1 -0
  148. package/dist/server/actions/getClientOrigin.d.ts.map +1 -0
  149. package/dist/server/actions/getClientOrigin.js +16 -0
  150. package/dist/server/actions/getClientOrigin.js.map +1 -0
  151. package/dist/server/actions/getSessionId.d.ts.map +1 -0
  152. package/dist/{getSessionId-_7hj8QSX.js → server/actions/getSessionId.js} +8 -5
  153. package/dist/server/actions/getSessionId.js.map +1 -0
  154. package/dist/server/actions/getSessionPayload.d.ts.map +1 -0
  155. package/dist/server/actions/getSessionPayload.js +27 -0
  156. package/dist/server/actions/getSessionPayload.js.map +1 -0
  157. package/dist/server/actions/getUserAction.d.ts.map +1 -0
  158. package/dist/server/actions/getUserAction.js +30 -0
  159. package/dist/server/actions/getUserAction.js.map +1 -0
  160. package/dist/server/actions/getUserProfileAction.d.ts.map +1 -0
  161. package/dist/server/actions/getUserProfileAction.js +34 -0
  162. package/dist/server/actions/getUserProfileAction.js.map +1 -0
  163. package/dist/server/actions/handleOAuthCallbackAction.d.ts.map +1 -0
  164. package/dist/server/actions/handleOAuthCallbackAction.js +87 -0
  165. package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -0
  166. package/dist/server/actions/isSignedIn.d.ts.map +1 -0
  167. package/dist/server/actions/isSignedIn.js +40 -0
  168. package/dist/server/actions/isSignedIn.js.map +1 -0
  169. package/dist/server/actions/refreshToken.d.ts.map +1 -0
  170. package/dist/server/actions/refreshToken.js +58 -0
  171. package/dist/server/actions/refreshToken.js.map +1 -0
  172. package/dist/server/actions/signInAction.d.ts.map +1 -0
  173. package/dist/server/actions/signInAction.js +92 -0
  174. package/dist/server/actions/signInAction.js.map +1 -0
  175. package/dist/server/actions/signOutAction.d.ts.map +1 -0
  176. package/dist/server/actions/signOutAction.js +55 -0
  177. package/dist/server/actions/signOutAction.js.map +1 -0
  178. package/dist/server/actions/signUpAction.d.ts.map +1 -0
  179. package/dist/server/actions/signUpAction.js +27 -0
  180. package/dist/server/actions/signUpAction.js.map +1 -0
  181. package/dist/server/actions/updateUserProfileAction.d.ts.map +1 -0
  182. package/dist/server/actions/updateUserProfileAction.js +30 -0
  183. package/dist/server/actions/updateUserProfileAction.js.map +1 -0
  184. package/dist/server/getClient.d.ts.map +1 -0
  185. package/dist/server/getClient.js +19 -0
  186. package/dist/server/getClient.js.map +1 -0
  187. package/dist/{types/server → server}/index.d.ts +3 -0
  188. package/dist/server/index.d.ts.map +1 -0
  189. package/dist/server/index.js +6 -0
  190. package/dist/server/proxy/createRouteMatcher.d.ts.map +1 -0
  191. package/dist/server/proxy/createRouteMatcher.js +35 -0
  192. package/dist/server/proxy/createRouteMatcher.js.map +1 -0
  193. package/dist/{types/server/middleware/thunderIDMiddleware.d.ts → server/proxy/thunderIDProxy.d.ts} +13 -13
  194. package/dist/server/proxy/thunderIDProxy.d.ts.map +1 -0
  195. package/dist/server/proxy/thunderIDProxy.js +180 -0
  196. package/dist/server/proxy/thunderIDProxy.js.map +1 -0
  197. package/dist/server/thunderid.d.ts.map +1 -0
  198. package/dist/server/thunderid.js +27 -0
  199. package/dist/server/thunderid.js.map +1 -0
  200. package/dist/utils/SessionManager.d.ts.map +1 -0
  201. package/dist/utils/SessionManager.js +147 -0
  202. package/dist/utils/SessionManager.js.map +1 -0
  203. package/dist/utils/createRouteMatcher.d.ts.map +1 -0
  204. package/dist/utils/decorateConfigWithNextEnv.d.ts.map +1 -0
  205. package/dist/utils/decorateConfigWithNextEnv.js +27 -0
  206. package/dist/utils/decorateConfigWithNextEnv.js.map +1 -0
  207. package/dist/utils/handleRefreshToken.d.ts.map +1 -0
  208. package/dist/utils/handleRefreshToken.js +62 -0
  209. package/dist/utils/handleRefreshToken.js.map +1 -0
  210. package/dist/utils/logger.d.ts.map +1 -0
  211. package/dist/utils/logger.js +9 -0
  212. package/dist/utils/logger.js.map +1 -0
  213. package/dist/utils/sessionUtils.d.ts.map +1 -0
  214. package/dist/utils/sessionUtils.js +39 -0
  215. package/dist/utils/sessionUtils.js.map +1 -0
  216. package/package.json +6 -16
  217. package/dist/SessionManager-BvmZ19QF.js +0 -1384
  218. package/dist/cache-DOmEIb7_.js +0 -6329
  219. package/dist/cjs/SessionManager-x03qrCM_.js +0 -1397
  220. package/dist/cjs/cache-Bw8u7jYk.js +0 -6332
  221. package/dist/cjs/dynamic-rendering-DY0EUx64.js +0 -1510
  222. package/dist/cjs/getAccessToken-eJk739AD.js +0 -22
  223. package/dist/cjs/getSessionId-BXqdO0BZ.js +0 -28
  224. package/dist/cjs/getSessionId-j-ERy_WP.js +0 -5
  225. package/dist/cjs/index2.cjs +0 -8
  226. package/dist/cjs/middleware.cjs +0 -5151
  227. package/dist/cjs/segment-CViTHaAn.js +0 -52
  228. package/dist/cjs/server-ABSmm73r.js +0 -2426
  229. package/dist/dynamic-rendering-CXn-s32e.js +0 -1429
  230. package/dist/getSessionId-6IipYdCB.js +0 -5
  231. package/dist/index2.js +0 -7
  232. package/dist/middleware.js +0 -5152
  233. package/dist/segment-DRUZ6e3T.js +0 -47
  234. package/dist/server-BUNp5d6D.js +0 -2376
  235. package/dist/types/ThunderIDNextClient.d.ts.map +0 -1
  236. package/dist/types/client/components/actions/SignInButton/SignInButton.d.ts.map +0 -1
  237. package/dist/types/client/components/actions/SignOutButton/SignOutButton.d.ts.map +0 -1
  238. package/dist/types/client/components/actions/SignUpButton/SignUpButton.d.ts.map +0 -1
  239. package/dist/types/client/components/control/Loading/Loading.d.ts.map +0 -1
  240. package/dist/types/client/components/control/SignedIn/SignedIn.d.ts.map +0 -1
  241. package/dist/types/client/components/control/SignedOut/SignedOut.d.ts.map +0 -1
  242. package/dist/types/client/components/presentation/CreateOrganization/CreateOrganization.d.ts +0 -68
  243. package/dist/types/client/components/presentation/CreateOrganization/CreateOrganization.d.ts.map +0 -1
  244. package/dist/types/client/components/presentation/Organization/Organization.d.ts +0 -67
  245. package/dist/types/client/components/presentation/Organization/Organization.d.ts.map +0 -1
  246. package/dist/types/client/components/presentation/OrganizationList/OrganizationList.d.ts +0 -93
  247. package/dist/types/client/components/presentation/OrganizationList/OrganizationList.d.ts.map +0 -1
  248. package/dist/types/client/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +0 -120
  249. package/dist/types/client/components/presentation/OrganizationProfile/OrganizationProfile.d.ts.map +0 -1
  250. package/dist/types/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +0 -72
  251. package/dist/types/client/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts.map +0 -1
  252. package/dist/types/client/components/presentation/SignIn/SignIn.d.ts.map +0 -1
  253. package/dist/types/client/components/presentation/SignUp/SignUp.d.ts.map +0 -1
  254. package/dist/types/client/components/presentation/User/User.d.ts.map +0 -1
  255. package/dist/types/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +0 -1
  256. package/dist/types/client/components/presentation/UserProfile/UserProfile.d.ts.map +0 -1
  257. package/dist/types/client/contexts/ThunderID/ThunderIDContext.d.ts.map +0 -1
  258. package/dist/types/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +0 -1
  259. package/dist/types/client/contexts/ThunderID/useThunderID.d.ts.map +0 -1
  260. package/dist/types/client/index.d.ts.map +0 -1
  261. package/dist/types/configs/InternalAuthAPIRoutesConfig.d.ts.map +0 -1
  262. package/dist/types/constants/sessionConstants.d.ts.map +0 -1
  263. package/dist/types/index.d.ts.map +0 -1
  264. package/dist/types/middleware.d.ts +0 -35
  265. package/dist/types/middleware.d.ts.map +0 -1
  266. package/dist/types/models/api.d.ts.map +0 -1
  267. package/dist/types/models/config.d.ts.map +0 -1
  268. package/dist/types/server/ThunderIDProvider.d.ts.map +0 -1
  269. package/dist/types/server/actions/clearSession.d.ts.map +0 -1
  270. package/dist/types/server/actions/createOrganization.d.ts +0 -24
  271. package/dist/types/server/actions/createOrganization.d.ts.map +0 -1
  272. package/dist/types/server/actions/getAccessToken.d.ts.map +0 -1
  273. package/dist/types/server/actions/getAllOrganizations.d.ts +0 -24
  274. package/dist/types/server/actions/getAllOrganizations.d.ts.map +0 -1
  275. package/dist/types/server/actions/getBrandingPreference.d.ts +0 -24
  276. package/dist/types/server/actions/getBrandingPreference.d.ts.map +0 -1
  277. package/dist/types/server/actions/getClientOrigin.d.ts.map +0 -1
  278. package/dist/types/server/actions/getCurrentOrganizationAction.d.ts +0 -31
  279. package/dist/types/server/actions/getCurrentOrganizationAction.d.ts.map +0 -1
  280. package/dist/types/server/actions/getMyOrganizations.d.ts +0 -24
  281. package/dist/types/server/actions/getMyOrganizations.d.ts.map +0 -1
  282. package/dist/types/server/actions/getOrganizationAction.d.ts +0 -31
  283. package/dist/types/server/actions/getOrganizationAction.d.ts.map +0 -1
  284. package/dist/types/server/actions/getSessionId.d.ts.map +0 -1
  285. package/dist/types/server/actions/getSessionPayload.d.ts.map +0 -1
  286. package/dist/types/server/actions/getUserAction.d.ts.map +0 -1
  287. package/dist/types/server/actions/getUserProfileAction.d.ts.map +0 -1
  288. package/dist/types/server/actions/handleOAuthCallbackAction.d.ts.map +0 -1
  289. package/dist/types/server/actions/isSignedIn.d.ts.map +0 -1
  290. package/dist/types/server/actions/refreshToken.d.ts.map +0 -1
  291. package/dist/types/server/actions/signInAction.d.ts.map +0 -1
  292. package/dist/types/server/actions/signOutAction.d.ts.map +0 -1
  293. package/dist/types/server/actions/signUpAction.d.ts.map +0 -1
  294. package/dist/types/server/actions/switchOrganization.d.ts +0 -24
  295. package/dist/types/server/actions/switchOrganization.d.ts.map +0 -1
  296. package/dist/types/server/actions/updateUserProfileAction.d.ts.map +0 -1
  297. package/dist/types/server/getClient.d.ts.map +0 -1
  298. package/dist/types/server/index.d.ts.map +0 -1
  299. package/dist/types/server/middleware/createRouteMatcher.d.ts.map +0 -1
  300. package/dist/types/server/middleware/thunderIDMiddleware.d.ts.map +0 -1
  301. package/dist/types/server/thunderid.d.ts.map +0 -1
  302. package/dist/types/utils/SessionManager.d.ts.map +0 -1
  303. package/dist/types/utils/createRouteMatcher.d.ts.map +0 -1
  304. package/dist/types/utils/decorateConfigWithNextEnv.d.ts.map +0 -1
  305. package/dist/types/utils/handleRefreshToken.d.ts.map +0 -1
  306. package/dist/types/utils/logger.d.ts.map +0 -1
  307. package/dist/types/utils/sessionUtils.d.ts.map +0 -1
  308. /package/dist/{types/client → client}/components/actions/SignInButton/SignInButton.d.ts +0 -0
  309. /package/dist/{types/client → client}/components/actions/SignOutButton/SignOutButton.d.ts +0 -0
  310. /package/dist/{types/client → client}/components/actions/SignUpButton/SignUpButton.d.ts +0 -0
  311. /package/dist/{types/client → client}/components/control/Loading/Loading.d.ts +0 -0
  312. /package/dist/{types/client → client}/components/control/SignedIn/SignedIn.d.ts +0 -0
  313. /package/dist/{types/client → client}/components/control/SignedOut/SignedOut.d.ts +0 -0
  314. /package/dist/{types/client → client}/components/presentation/SignIn/SignIn.d.ts +0 -0
  315. /package/dist/{types/client → client}/components/presentation/SignUp/SignUp.d.ts +0 -0
  316. /package/dist/{types/client → client}/components/presentation/User/User.d.ts +0 -0
  317. /package/dist/{types/client → client}/components/presentation/UserDropdown/UserDropdown.d.ts +0 -0
  318. /package/dist/{types/client → client}/components/presentation/UserProfile/UserProfile.d.ts +0 -0
  319. /package/dist/{types/client → client}/contexts/ThunderID/ThunderIDContext.d.ts +0 -0
  320. /package/dist/{types/client → client}/contexts/ThunderID/useThunderID.d.ts +0 -0
  321. /package/dist/{types/configs → configs}/InternalAuthAPIRoutesConfig.d.ts +0 -0
  322. /package/dist/{types/constants → constants}/sessionConstants.d.ts +0 -0
  323. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  324. /package/dist/{types/models → models}/api.d.ts +0 -0
  325. /package/dist/{types/models → models}/config.d.ts +0 -0
  326. /package/dist/{types/server → server}/ThunderIDProvider.d.ts +0 -0
  327. /package/dist/{types/server → server}/actions/clearSession.d.ts +0 -0
  328. /package/dist/{types/server → server}/actions/getAccessToken.d.ts +0 -0
  329. /package/dist/{types/server → server}/actions/getClientOrigin.d.ts +0 -0
  330. /package/dist/{types/server → server}/actions/getSessionId.d.ts +0 -0
  331. /package/dist/{types/server → server}/actions/getSessionPayload.d.ts +0 -0
  332. /package/dist/{types/server → server}/actions/getUserAction.d.ts +0 -0
  333. /package/dist/{types/server → server}/actions/getUserProfileAction.d.ts +0 -0
  334. /package/dist/{types/server → server}/actions/handleOAuthCallbackAction.d.ts +0 -0
  335. /package/dist/{types/server → server}/actions/isSignedIn.d.ts +0 -0
  336. /package/dist/{types/server → server}/actions/refreshToken.d.ts +0 -0
  337. /package/dist/{types/server → server}/actions/signInAction.d.ts +0 -0
  338. /package/dist/{types/server → server}/actions/signOutAction.d.ts +0 -0
  339. /package/dist/{types/server → server}/actions/signUpAction.d.ts +0 -0
  340. /package/dist/{types/server → server}/actions/updateUserProfileAction.d.ts +0 -0
  341. /package/dist/{types/server → server}/getClient.d.ts +0 -0
  342. /package/dist/{types/server/middleware → server/proxy}/createRouteMatcher.d.ts +0 -0
  343. /package/dist/{types/server → server}/thunderid.d.ts +0 -0
  344. /package/dist/{types/utils → utils}/SessionManager.d.ts +0 -0
  345. /package/dist/{types/utils → utils}/createRouteMatcher.d.ts +0 -0
  346. /package/dist/{types/utils → utils}/decorateConfigWithNextEnv.d.ts +0 -0
  347. /package/dist/{types/utils → utils}/handleRefreshToken.d.ts +0 -0
  348. /package/dist/{types/utils → utils}/logger.d.ts +0 -0
  349. /package/dist/{types/utils → utils}/sessionUtils.d.ts +0 -0
@@ -0,0 +1,114 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
5
+ const require_getSessionId = require('./actions/getSessionId.cjs');
6
+ const require_getClient = require('./getClient.cjs');
7
+ const require_logger = require('../utils/logger.cjs');
8
+ const require_clearSession = require('./actions/clearSession.cjs');
9
+ const require_getSessionPayload = require('./actions/getSessionPayload.cjs');
10
+ const require_getUserAction = require('./actions/getUserAction.cjs');
11
+ const require_getUserProfileAction = require('./actions/getUserProfileAction.cjs');
12
+ const require_handleOAuthCallbackAction = require('./actions/handleOAuthCallbackAction.cjs');
13
+ const require_isSignedIn = require('./actions/isSignedIn.cjs');
14
+ const require_refreshToken = require('./actions/refreshToken.cjs');
15
+ const require_signInAction = require('./actions/signInAction.cjs');
16
+ const require_signOutAction = require('./actions/signOutAction.cjs');
17
+ const require_signUpAction = require('./actions/signUpAction.cjs');
18
+ const require_updateUserProfileAction = require('./actions/updateUserProfileAction.cjs');
19
+ const require_ThunderIDProvider = require('../client/contexts/ThunderID/ThunderIDProvider.cjs');
20
+ let __thunderid_node = require("@thunderid/node");
21
+ __thunderid_node = require_rolldown_runtime.__toESM(__thunderid_node);
22
+ let react_jsx_runtime = require("react/jsx-runtime");
23
+ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
24
+
25
+ //#region src/server/ThunderIDProvider.tsx
26
+ /**
27
+ * Server-side provider component for ThunderID authentication.
28
+ * Wraps the client-side provider and handles server-side authentication logic.
29
+ * Uses the singleton ThunderIDNextClient instance for consistent authentication state.
30
+ *
31
+ * @param props - Props injected into the component.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * <ThunderIDServerProvider config={thunderidConfig}>
36
+ * <YourApp />
37
+ * </ThunderIDServerProvider>
38
+ * ```
39
+ *
40
+ * @returns ThunderIDServerProvider component.
41
+ */
42
+ const ThunderIDServerProvider = async ({ children, afterSignInUrl, afterSignOutUrl,..._config }) => {
43
+ const thunderIDClient = require_getClient.default();
44
+ let config = {};
45
+ try {
46
+ await thunderIDClient.initialize(_config);
47
+ require_logger.default.debug("[ThunderIDServerProvider] ThunderID client initialized successfully.");
48
+ config = await thunderIDClient.getConfiguration();
49
+ } catch (error) {
50
+ require_logger.default.error("[ThunderIDServerProvider] Failed to initialize ThunderID client:", error?.toString());
51
+ throw new __thunderid_node.ThunderIDRuntimeError(`Failed to initialize ThunderID client: ${error?.toString()}`, "next-ConfigurationError-001", "next", "An error occurred while initializing the ThunderID client. Please check your configuration.");
52
+ }
53
+ if (!thunderIDClient.isInitialized) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
54
+ const sessionPayload = await require_getSessionPayload.default();
55
+ const sessionId = sessionPayload?.sessionId || await require_getSessionId.default() || "";
56
+ const signedIn = await require_isSignedIn.default(sessionId);
57
+ let user = {};
58
+ let userProfile = {
59
+ flattenedProfile: {},
60
+ profile: {},
61
+ schemas: []
62
+ };
63
+ if (signedIn) {
64
+ let updatedBaseUrl = config?.baseUrl;
65
+ if (sessionPayload?.organizationId) {
66
+ updatedBaseUrl = `${config?.baseUrl}/o`;
67
+ config = {
68
+ ...config,
69
+ baseUrl: updatedBaseUrl
70
+ };
71
+ } else if (sessionId) try {
72
+ if ((await thunderIDClient.getDecodedIdToken(sessionId))?.["user_org"]) {
73
+ updatedBaseUrl = `${config?.baseUrl}/o`;
74
+ config = {
75
+ ...config,
76
+ baseUrl: updatedBaseUrl
77
+ };
78
+ }
79
+ } catch {}
80
+ if (config?.preferences?.user?.fetchUserProfile !== false) try {
81
+ const userResponse = await require_getUserAction.default(sessionId);
82
+ const userProfileResponse = await require_getUserProfileAction.default(sessionId);
83
+ user = userResponse.data?.user || {};
84
+ userProfile = userProfileResponse.data?.userProfile ?? userProfile;
85
+ } catch (error) {
86
+ require_logger.default.warn("[ThunderIDServerProvider] Failed to fetch user profile from SCIM2:", error?.toString());
87
+ }
88
+ }
89
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ThunderIDProvider.default, {
90
+ organizationHandle: config?.organizationHandle,
91
+ applicationId: config?.applicationId,
92
+ baseUrl: config?.baseUrl,
93
+ signIn: require_signInAction.default,
94
+ clearSession: require_clearSession.default,
95
+ refreshToken: require_refreshToken.default,
96
+ signOut: require_signOutAction.default,
97
+ signUp: require_signUpAction.default,
98
+ handleOAuthCallback: require_handleOAuthCallbackAction.default,
99
+ signInUrl: config?.signInUrl,
100
+ signUpUrl: config?.signUpUrl,
101
+ preferences: config?.preferences,
102
+ clientId: config?.clientId,
103
+ user,
104
+ userProfile,
105
+ updateProfile: require_updateUserProfileAction.default,
106
+ isSignedIn: signedIn,
107
+ children
108
+ });
109
+ };
110
+ var ThunderIDProvider_default$1 = ThunderIDServerProvider;
111
+
112
+ //#endregion
113
+ exports.default = ThunderIDProvider_default$1;
114
+ //# sourceMappingURL=ThunderIDProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThunderIDProvider.cjs","names":["ThunderIDServerProvider: FC<PropsWithChildren<ThunderIDServerProviderProps>>","getClient","config: Partial<ThunderIDNextConfig>","ThunderIDRuntimeError","sessionPayload: SessionTokenPayload | undefined","getSessionPayload","sessionId: string","getSessionId","signedIn: boolean","isSignedIn","user: User","userProfile: UserProfile","updatedBaseUrl: string | undefined","userResponse: {\n data: {user: User | null};\n error: string | null;\n success: boolean;\n }","getUserAction","userProfileResponse: {\n data: {userProfile: UserProfile};\n error: string | null;\n success: boolean;\n }","getUserProfileAction","ThunderIDClientProvider","signInAction","clearSession","refreshToken","signOutAction","signUpAction","handleOAuthCallbackAction","updateUserProfileAction"],"sources":["../../../src/server/ThunderIDProvider.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 server';\n\nimport {ThunderIDRuntimeError, IdToken, User, UserProfile} from '@thunderid/node';\nimport {ThunderIDProviderProps} from '@thunderid/react';\nimport {FC, PropsWithChildren, ReactElement} from 'react';\nimport clearSession from './actions/clearSession';\nimport getSessionId from './actions/getSessionId';\nimport getSessionPayload from './actions/getSessionPayload';\nimport getUserAction from './actions/getUserAction';\nimport getUserProfileAction from './actions/getUserProfileAction';\nimport handleOAuthCallbackAction from './actions/handleOAuthCallbackAction';\nimport isSignedIn from './actions/isSignedIn';\nimport refreshToken from './actions/refreshToken';\nimport signInAction from './actions/signInAction';\nimport signOutAction from './actions/signOutAction';\nimport signUpAction from './actions/signUpAction';\nimport updateUserProfileAction from './actions/updateUserProfileAction';\nimport getClient from './getClient';\nimport ThunderIDClientProvider from '../client/contexts/ThunderID/ThunderIDProvider.js';\nimport {ThunderIDNextConfig} from '../models/config';\nimport logger from '../utils/logger';\nimport {SessionTokenPayload} from '../utils/SessionManager';\n\n/**\n * Props interface of {@link ThunderIDServerProvider}\n */\nexport type ThunderIDServerProviderProps = Partial<ThunderIDProviderProps> & {\n clientSecret?: string;\n /**\n * Session cookie lifetime in seconds. Determines how long the session cookie\n * remains valid in the browser after sign-in.\n *\n * Resolution order (first defined value wins):\n * 1. This prop — set here when mounting the provider.\n * 2. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME` environment variable.\n * 3. Built-in default of 86400 seconds (24 hours).\n *\n * @example\n * // 8-hour session cookie\n * <ThunderIDServerProvider sessionCookieExpiryTime={28800} ... />\n */\n sessionCookieExpiryTime?: number;\n};\n\n/**\n * Server-side provider component for ThunderID authentication.\n * Wraps the client-side provider and handles server-side authentication logic.\n * Uses the singleton ThunderIDNextClient instance for consistent authentication state.\n *\n * @param props - Props injected into the component.\n *\n * @example\n * ```tsx\n * <ThunderIDServerProvider config={thunderidConfig}>\n * <YourApp />\n * </ThunderIDServerProvider>\n * ```\n *\n * @returns ThunderIDServerProvider component.\n */\nconst ThunderIDServerProvider: FC<PropsWithChildren<ThunderIDServerProviderProps>> = async ({\n children,\n afterSignInUrl,\n afterSignOutUrl,\n ..._config\n}: PropsWithChildren<ThunderIDServerProviderProps>): Promise<ReactElement> => {\n const thunderIDClient = getClient();\n let config: Partial<ThunderIDNextConfig> = {};\n\n try {\n await thunderIDClient.initialize(_config as ThunderIDNextConfig);\n\n logger.debug('[ThunderIDServerProvider] ThunderID client initialized successfully.');\n\n config = await thunderIDClient.getConfiguration();\n } catch (error) {\n logger.error('[ThunderIDServerProvider] Failed to initialize ThunderID client:', error?.toString());\n\n throw new ThunderIDRuntimeError(\n `Failed to initialize ThunderID client: ${error?.toString()}`,\n 'next-ConfigurationError-001',\n 'next',\n 'An error occurred while initializing the ThunderID client. Please check your configuration.',\n );\n }\n\n if (!thunderIDClient.isInitialized) {\n return <></>;\n }\n\n // Try to get session information from JWT first, then fall back to legacy\n const sessionPayload: SessionTokenPayload | undefined = await getSessionPayload();\n const sessionId: string = sessionPayload?.sessionId || (await getSessionId()) || '';\n const signedIn: boolean = await isSignedIn(sessionId);\n\n let user: User = {};\n let userProfile: UserProfile = {\n flattenedProfile: {},\n profile: {},\n schemas: [],\n };\n if (signedIn) {\n let updatedBaseUrl: string | undefined = config?.baseUrl;\n\n if (sessionPayload?.organizationId) {\n updatedBaseUrl = `${config?.baseUrl}/o`;\n config = {...config, baseUrl: updatedBaseUrl};\n } else if (sessionId) {\n try {\n const idToken: IdToken = await thunderIDClient.getDecodedIdToken(sessionId);\n if (idToken?.['user_org']) {\n updatedBaseUrl = `${config?.baseUrl}/o`;\n config = {...config, baseUrl: updatedBaseUrl};\n }\n } catch {\n // Continue without organization info\n }\n }\n\n // Check if user profile fetching is enabled (default: true)\n const shouldFetchUserProfile: boolean = config?.preferences?.user?.fetchUserProfile !== false;\n\n if (shouldFetchUserProfile) {\n try {\n const userResponse: {\n data: {user: User | null};\n error: string | null;\n success: boolean;\n } = await getUserAction(sessionId);\n const userProfileResponse: {\n data: {userProfile: UserProfile};\n error: string | null;\n success: boolean;\n } = await getUserProfileAction(sessionId);\n\n user = userResponse.data?.user || {};\n userProfile = userProfileResponse.data?.userProfile ?? userProfile;\n } catch (error) {\n logger.warn('[ThunderIDServerProvider] Failed to fetch user profile from SCIM2:', error?.toString());\n }\n }\n }\n\n return (\n <ThunderIDClientProvider\n organizationHandle={config?.organizationHandle}\n applicationId={config?.applicationId}\n baseUrl={config?.baseUrl}\n signIn={signInAction}\n clearSession={clearSession}\n refreshToken={refreshToken}\n signOut={signOutAction}\n signUp={signUpAction}\n handleOAuthCallback={handleOAuthCallbackAction}\n signInUrl={config?.signInUrl}\n signUpUrl={config?.signUpUrl}\n preferences={config?.preferences}\n clientId={config?.clientId}\n user={user}\n userProfile={userProfile}\n updateProfile={updateUserProfileAction}\n isSignedIn={signedIn}\n >\n {children}\n </ThunderIDClientProvider>\n );\n};\n\nexport default ThunderIDServerProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAMA,0BAA+E,OAAO,EAC1F,UACA,gBACA,gBACA,GAAG,cACyE;CAC5E,MAAM,kBAAkBC,2BAAW;CACnC,IAAIC,SAAuC,EAAE;AAE7C,KAAI;AACF,QAAM,gBAAgB,WAAW,QAA+B;AAEhE,yBAAO,MAAM,uEAAuE;AAEpF,WAAS,MAAM,gBAAgB,kBAAkB;UAC1C,OAAO;AACd,yBAAO,MAAM,oEAAoE,OAAO,UAAU,CAAC;AAEnG,QAAM,IAAIC,uCACR,0CAA0C,OAAO,UAAU,IAC3D,+BACA,QACA,8FACD;;AAGH,KAAI,CAAC,gBAAgB,cACnB,QAAO,0EAAK;CAId,MAAMC,iBAAkD,MAAMC,mCAAmB;CACjF,MAAMC,YAAoB,gBAAgB,aAAc,MAAMC,8BAAc,IAAK;CACjF,MAAMC,WAAoB,MAAMC,2BAAW,UAAU;CAErD,IAAIC,OAAa,EAAE;CACnB,IAAIC,cAA2B;EAC7B,kBAAkB,EAAE;EACpB,SAAS,EAAE;EACX,SAAS,EAAE;EACZ;AACD,KAAI,UAAU;EACZ,IAAIC,iBAAqC,QAAQ;AAEjD,MAAI,gBAAgB,gBAAgB;AAClC,oBAAiB,GAAG,QAAQ,QAAQ;AACpC,YAAS;IAAC,GAAG;IAAQ,SAAS;IAAe;aACpC,UACT,KAAI;AAEF,QADyB,MAAM,gBAAgB,kBAAkB,UAAU,IAC7D,aAAa;AACzB,qBAAiB,GAAG,QAAQ,QAAQ;AACpC,aAAS;KAAC,GAAG;KAAQ,SAAS;KAAe;;UAEzC;AAQV,MAFwC,QAAQ,aAAa,MAAM,qBAAqB,MAGtF,KAAI;GACF,MAAMC,eAIF,MAAMC,8BAAc,UAAU;GAClC,MAAMC,sBAIF,MAAMC,qCAAqB,UAAU;AAEzC,UAAO,aAAa,MAAM,QAAQ,EAAE;AACpC,iBAAc,oBAAoB,MAAM,eAAe;WAChD,OAAO;AACd,0BAAO,KAAK,sEAAsE,OAAO,UAAU,CAAC;;;AAK1G,QACE,2CAACC;EACC,oBAAoB,QAAQ;EAC5B,eAAe,QAAQ;EACvB,SAAS,QAAQ;EACjB,QAAQC;EACR,cAAcC;EACd,cAAcC;EACd,SAASC;EACT,QAAQC;EACR,qBAAqBC;EACrB,WAAW,QAAQ;EACnB,WAAW,QAAQ;EACnB,aAAa,QAAQ;EACrB,UAAU,QAAQ;EACZ;EACO;EACb,eAAeC;EACf,YAAY;EAEX;GACuB;;AAI9B,kCAAe"}
@@ -0,0 +1,41 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ const require_logger = require('../../utils/logger.cjs');
7
+ let next_headers = require("next/headers");
8
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
9
+
10
+ //#region src/server/actions/clearSession.ts
11
+ /**
12
+ * Deletes all ThunderID session cookies from the browser without contacting the
13
+ * identity server.
14
+ *
15
+ * Use this for error-recovery scenarios where the local session must be wiped
16
+ * immediately: refresh token failures, corrupt sessions, or forced local sign-out
17
+ * when the identity server is unreachable.
18
+ *
19
+ * For a complete sign-out that also revokes the server-side session and obtains the
20
+ * after-sign-out redirect URL, use `signOutAction` instead.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { clearSession } from '@thunderid/nextjs/server';
25
+ *
26
+ * // Inside a Server Action or Route Handler:
27
+ * await clearSession();
28
+ * redirect('/sign-in');
29
+ * ```
30
+ */
31
+ const clearSession = async () => {
32
+ const cookieStore = await (0, next_headers.cookies)();
33
+ cookieStore.delete(require_SessionManager.default.getSessionCookieName());
34
+ cookieStore.delete(require_SessionManager.default.getTempSessionCookieName());
35
+ require_logger.default.debug("[clearSession] Session cookies cleared.");
36
+ };
37
+ var clearSession_default = clearSession;
38
+
39
+ //#endregion
40
+ exports.default = clearSession_default;
41
+ //# sourceMappingURL=clearSession.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clearSession.cjs","names":["cookieStore: RequestCookies","SessionManager"],"sources":["../../../../src/server/actions/clearSession.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\n'use server';\n\nimport {cookies} from 'next/headers';\nimport logger from '../../utils/logger';\nimport SessionManager from '../../utils/SessionManager';\n\ntype RequestCookies = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Deletes all ThunderID session cookies from the browser without contacting the\n * identity server.\n *\n * Use this for error-recovery scenarios where the local session must be wiped\n * immediately: refresh token failures, corrupt sessions, or forced local sign-out\n * when the identity server is unreachable.\n *\n * For a complete sign-out that also revokes the server-side session and obtains the\n * after-sign-out redirect URL, use `signOutAction` instead.\n *\n * @example\n * ```typescript\n * import { clearSession } from '@thunderid/nextjs/server';\n *\n * // Inside a Server Action or Route Handler:\n * await clearSession();\n * redirect('/sign-in');\n * ```\n */\nconst clearSession = async (): Promise<void> => {\n const cookieStore: RequestCookies = await cookies();\n cookieStore.delete(SessionManager.getSessionCookieName());\n cookieStore.delete(SessionManager.getTempSessionCookieName());\n logger.debug('[clearSession] Session cookies cleared.');\n};\n\nexport default clearSession;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,eAAe,YAA2B;CAC9C,MAAMA,cAA8B,iCAAe;AACnD,aAAY,OAAOC,+BAAe,sBAAsB,CAAC;AACzD,aAAY,OAAOA,+BAAe,0BAA0B,CAAC;AAC7D,wBAAO,MAAM,0CAA0C;;AAGzD,2BAAe"}
@@ -0,0 +1,27 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ let next_headers = require("next/headers");
7
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
8
+
9
+ //#region src/server/actions/getAccessToken.ts
10
+ /**
11
+ * Get the access token from the session cookie.
12
+ *
13
+ * @returns The access token if it exists, undefined otherwise
14
+ */
15
+ const getAccessToken = async () => {
16
+ const sessionToken = (await (0, next_headers.cookies)()).get(require_SessionManager.default.getSessionCookieName())?.value;
17
+ if (sessionToken) try {
18
+ return (await require_SessionManager.default.verifySessionToken(sessionToken))["accessToken"];
19
+ } catch (error) {
20
+ return;
21
+ }
22
+ };
23
+ var getAccessToken_default = getAccessToken;
24
+
25
+ //#endregion
26
+ exports.default = getAccessToken_default;
27
+ //# sourceMappingURL=getAccessToken.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAccessToken.cjs","names":["sessionToken: string | undefined","SessionManager"],"sources":["../../../../src/server/actions/getAccessToken.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\n'use server';\n\nimport {cookies} from 'next/headers';\nimport SessionManager, {SessionTokenPayload} from '../../utils/SessionManager';\n\ntype RequestCookies = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Get the access token from the session cookie.\n *\n * @returns The access token if it exists, undefined otherwise\n */\nconst getAccessToken = async (): Promise<string | undefined> => {\n const cookieStore: RequestCookies = await cookies();\n\n const sessionToken: string | undefined = cookieStore.get(SessionManager.getSessionCookieName())?.value;\n\n if (sessionToken) {\n try {\n const sessionPayload: SessionTokenPayload = await SessionManager.verifySessionToken(sessionToken);\n\n return sessionPayload['accessToken'] as string;\n } catch (error) {\n return undefined;\n }\n }\n\n return undefined;\n};\n\nexport default getAccessToken;\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,iBAAiB,YAAyC;CAG9D,MAAMA,gBAF8B,iCAAe,EAEE,IAAIC,+BAAe,sBAAsB,CAAC,EAAE;AAEjG,KAAI,aACF,KAAI;AAGF,UAF4C,MAAMA,+BAAe,mBAAmB,aAAa,EAE3E;UACf,OAAO;AACd;;;AAON,6BAAe"}
@@ -0,0 +1,18 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ let next_headers = require("next/headers");
6
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
7
+
8
+ //#region src/server/actions/getClientOrigin.ts
9
+ const getClientOrigin = async () => {
10
+ const headersList = await (0, next_headers.headers)();
11
+ const host = headersList.get("host");
12
+ return `${headersList.get("x-forwarded-proto") ?? "http"}://${host}`;
13
+ };
14
+ var getClientOrigin_default = getClientOrigin;
15
+
16
+ //#endregion
17
+ exports.default = getClientOrigin_default;
18
+ //# sourceMappingURL=getClientOrigin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getClientOrigin.cjs","names":["headersList: ReadonlyHeaders","host: string | null"],"sources":["../../../../src/server/actions/getClientOrigin.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\n'use server';\n\nimport {ReadonlyHeaders} from 'next/dist/server/web/spec-extension/adapters/headers';\nimport {headers} from 'next/headers';\n\nconst getClientOrigin = async (): Promise<string> => {\n const headersList: ReadonlyHeaders = await headers();\n const host: string | null = headersList.get('host');\n const protocol: string = headersList.get('x-forwarded-proto') ?? 'http';\n return `${protocol}://${host}`;\n};\n\nexport default getClientOrigin;\n"],"mappings":";;;;;;;;AAuBA,MAAM,kBAAkB,YAA6B;CACnD,MAAMA,cAA+B,iCAAe;CACpD,MAAMC,OAAsB,YAAY,IAAI,OAAO;AAEnD,QAAO,GADkB,YAAY,IAAI,oBAAoB,IAAI,OAC9C,KAAK;;AAG1B,8BAAe"}
@@ -0,0 +1,28 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ let next_headers = require("next/headers");
7
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
8
+
9
+ //#region src/server/actions/getSessionId.ts
10
+ /**
11
+ * Get the session ID from cookies.
12
+ * Tries JWT session first, then falls back to legacy session ID.
13
+ *
14
+ * @returns The session ID if it exists, undefined otherwise
15
+ */
16
+ const getSessionId = async () => {
17
+ const sessionToken = (await (0, next_headers.cookies)()).get(require_SessionManager.default.getSessionCookieName())?.value;
18
+ if (sessionToken) try {
19
+ return (await require_SessionManager.default.verifySessionToken(sessionToken)).sessionId;
20
+ } catch (error) {
21
+ return;
22
+ }
23
+ };
24
+ var getSessionId_default = getSessionId;
25
+
26
+ //#endregion
27
+ exports.default = getSessionId_default;
28
+ //# sourceMappingURL=getSessionId.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSessionId.cjs","names":["sessionToken: string | undefined","SessionManager"],"sources":["../../../../src/server/actions/getSessionId.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\n'use server';\n\nimport {cookies} from 'next/headers';\nimport SessionManager, {SessionTokenPayload} from '../../utils/SessionManager';\n\ntype RequestCookies = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Get the session ID from cookies.\n * Tries JWT session first, then falls back to legacy session ID.\n *\n * @returns The session ID if it exists, undefined otherwise\n */\nconst getSessionId = async (): Promise<string | undefined> => {\n const cookieStore: RequestCookies = await cookies();\n\n const sessionToken: string | undefined = cookieStore.get(SessionManager.getSessionCookieName())?.value;\n\n if (sessionToken) {\n try {\n const sessionPayload: SessionTokenPayload = await SessionManager.verifySessionToken(sessionToken);\n\n return sessionPayload.sessionId;\n } catch (error) {\n return undefined;\n }\n }\n\n return undefined;\n};\n\nexport default getSessionId;\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,eAAe,YAAyC;CAG5D,MAAMA,gBAF8B,iCAAe,EAEE,IAAIC,+BAAe,sBAAsB,CAAC,EAAE;AAEjG,KAAI,aACF,KAAI;AAGF,UAF4C,MAAMA,+BAAe,mBAAmB,aAAa,EAE3E;UACf,OAAO;AACd;;;AAON,2BAAe"}
@@ -0,0 +1,29 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ let next_headers = require("next/headers");
7
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
8
+
9
+ //#region src/server/actions/getSessionPayload.ts
10
+ /**
11
+ * Get the session payload from JWT session cookie.
12
+ * This includes user ID, session ID, scopes, and organization ID.
13
+ *
14
+ * @returns The session payload if valid JWT session exists, undefined otherwise
15
+ */
16
+ const getSessionPayload = async () => {
17
+ const sessionToken = (await (0, next_headers.cookies)()).get(require_SessionManager.default.getSessionCookieName())?.value;
18
+ if (!sessionToken) return;
19
+ try {
20
+ return await require_SessionManager.default.verifySessionToken(sessionToken);
21
+ } catch {
22
+ return;
23
+ }
24
+ };
25
+ var getSessionPayload_default = getSessionPayload;
26
+
27
+ //#endregion
28
+ exports.default = getSessionPayload_default;
29
+ //# sourceMappingURL=getSessionPayload.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSessionPayload.cjs","names":["sessionToken: string | undefined","SessionManager"],"sources":["../../../../src/server/actions/getSessionPayload.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\n'use server';\n\nimport {cookies} from 'next/headers';\nimport SessionManager, {SessionTokenPayload} from '../../utils/SessionManager';\n\ntype RequestCookies = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Get the session payload from JWT session cookie.\n * This includes user ID, session ID, scopes, and organization ID.\n *\n * @returns The session payload if valid JWT session exists, undefined otherwise\n */\nconst getSessionPayload = async (): Promise<SessionTokenPayload | undefined> => {\n const cookieStore: RequestCookies = await cookies();\n\n const sessionToken: string | undefined = cookieStore.get(SessionManager.getSessionCookieName())?.value;\n if (!sessionToken) {\n return undefined;\n }\n\n try {\n return await SessionManager.verifySessionToken(sessionToken);\n } catch {\n return undefined;\n }\n};\n\nexport default getSessionPayload;\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,oBAAoB,YAAsD;CAG9E,MAAMA,gBAF8B,iCAAe,EAEE,IAAIC,+BAAe,sBAAsB,CAAC,EAAE;AACjG,KAAI,CAAC,aACH;AAGF,KAAI;AACF,SAAO,MAAMA,+BAAe,mBAAmB,aAAa;SACtD;AACN;;;AAIJ,gCAAe"}
@@ -0,0 +1,30 @@
1
+ 'use server';
2
+
3
+
4
+ const require_getClient = require('../getClient.cjs');
5
+
6
+ //#region src/server/actions/getUserAction.ts
7
+ /**
8
+ * Server action to get the current user.
9
+ * Returns the user profile if signed in.
10
+ */
11
+ const getUserAction = async (sessionId) => {
12
+ try {
13
+ return {
14
+ data: { user: await require_getClient.default().getUser(sessionId) },
15
+ error: null,
16
+ success: true
17
+ };
18
+ } catch (error) {
19
+ return {
20
+ data: { user: null },
21
+ error: "Failed to get user",
22
+ success: false
23
+ };
24
+ }
25
+ };
26
+ var getUserAction_default = getUserAction;
27
+
28
+ //#endregion
29
+ exports.default = getUserAction_default;
30
+ //# sourceMappingURL=getUserAction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUserAction.cjs","names":["getClient"],"sources":["../../../../src/server/actions/getUserAction.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\n'use server';\n\nimport {User} from '@thunderid/node';\nimport getClient from '../getClient';\n\n/**\n * Server action to get the current user.\n * Returns the user profile if signed in.\n */\nconst getUserAction = async (\n sessionId: string,\n): Promise<{data: {user: User | null}; error: string | null; success: boolean}> => {\n try {\n const client = getClient();\n const user: User = await client.getUser(sessionId);\n return {data: {user}, error: null, success: true};\n } catch (error) {\n return {data: {user: null}, error: 'Failed to get user', success: false};\n }\n};\n\nexport default getUserAction;\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,gBAAgB,OACpB,cACiF;AACjF,KAAI;AAGF,SAAO;GAAC,MAAM,EAAC,MADI,MADJA,2BAAW,CACM,QAAQ,UAAU,EAC9B;GAAE,OAAO;GAAM,SAAS;GAAK;UAC1C,OAAO;AACd,SAAO;GAAC,MAAM,EAAC,MAAM,MAAK;GAAE,OAAO;GAAsB,SAAS;GAAM;;;AAI5E,4BAAe"}
@@ -0,0 +1,34 @@
1
+ 'use server';
2
+
3
+
4
+ const require_getClient = require('../getClient.cjs');
5
+
6
+ //#region src/server/actions/getUserProfileAction.ts
7
+ /**
8
+ * Server action to get the current user.
9
+ * Returns the user profile if signed in.
10
+ */
11
+ const getUserProfileAction = async (sessionId) => {
12
+ try {
13
+ return {
14
+ data: { userProfile: await require_getClient.default().getUserProfile(sessionId) },
15
+ error: null,
16
+ success: true
17
+ };
18
+ } catch (error) {
19
+ return {
20
+ data: { userProfile: {
21
+ flattenedProfile: {},
22
+ profile: {},
23
+ schemas: []
24
+ } },
25
+ error: "Failed to get user profile",
26
+ success: false
27
+ };
28
+ }
29
+ };
30
+ var getUserProfileAction_default = getUserProfileAction;
31
+
32
+ //#endregion
33
+ exports.default = getUserProfileAction_default;
34
+ //# sourceMappingURL=getUserProfileAction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUserProfileAction.cjs","names":["getClient"],"sources":["../../../../src/server/actions/getUserProfileAction.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\n'use server';\n\nimport {UserProfile} from '@thunderid/node';\nimport getClient from '../getClient';\n\n/**\n * Server action to get the current user.\n * Returns the user profile if signed in.\n */\nconst getUserProfileAction = async (\n sessionId: string,\n): Promise<{data: {userProfile: UserProfile}; error: string | null; success: boolean}> => {\n try {\n const client = getClient();\n const updatedProfile: UserProfile = await client.getUserProfile(sessionId);\n return {data: {userProfile: updatedProfile}, error: null, success: true};\n } catch (error) {\n return {\n data: {\n userProfile: {\n flattenedProfile: {},\n profile: {},\n schemas: [],\n },\n },\n error: 'Failed to get user profile',\n success: false,\n };\n }\n};\n\nexport default getUserProfileAction;\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,uBAAuB,OAC3B,cACwF;AACxF,KAAI;AAGF,SAAO;GAAC,MAAM,EAAC,aADqB,MADrBA,2BAAW,CACuB,eAAe,UAAU,EAC/B;GAAE,OAAO;GAAM,SAAS;GAAK;UACjE,OAAO;AACd,SAAO;GACL,MAAM,EACJ,aAAa;IACX,kBAAkB,EAAE;IACpB,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,EACF;GACD,OAAO;GACP,SAAS;GACV;;;AAIL,mCAAe"}
@@ -0,0 +1,89 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ const require_getClient = require('../getClient.cjs');
7
+ const require_logger = require('../../utils/logger.cjs');
8
+ let next_headers = require("next/headers");
9
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
10
+
11
+ //#region src/server/actions/handleOAuthCallbackAction.ts
12
+ /**
13
+ * Server action to handle OAuth callback with authorization code.
14
+ * This action processes the authorization code received from the OAuth provider
15
+ * and exchanges it for tokens to complete the authentication flow.
16
+ *
17
+ * @param code - Authorization code from OAuth provider
18
+ * @param state - State parameter from OAuth provider for CSRF protection
19
+ * @param sessionState - Session state parameter from OAuth provider
20
+ * @returns Promise that resolves with success status and optional error message
21
+ */
22
+ const handleOAuthCallbackAction = async (code, state, sessionState) => {
23
+ try {
24
+ if (!code || !state) return {
25
+ error: "Missing required OAuth parameters: code and state are required",
26
+ success: false
27
+ };
28
+ const thunderIDClient = require_getClient.default();
29
+ if (!thunderIDClient.isInitialized) return {
30
+ error: "ThunderID client is not initialized",
31
+ success: false
32
+ };
33
+ const cookieStore = await (0, next_headers.cookies)();
34
+ let sessionId;
35
+ const tempSessionToken = cookieStore.get(require_SessionManager.default.getTempSessionCookieName())?.value;
36
+ if (tempSessionToken) try {
37
+ sessionId = (await require_SessionManager.default.verifyTempSession(tempSessionToken)).sessionId;
38
+ } catch {
39
+ require_logger.default.error("[handleOAuthCallbackAction] Invalid temporary session token, falling back to session ID from cookies.");
40
+ }
41
+ if (!sessionId) {
42
+ require_logger.default.error("[handleOAuthCallbackAction] No session ID found in cookies or temporary session token.");
43
+ return {
44
+ error: "No session found. Please start the authentication flow again.",
45
+ success: false
46
+ };
47
+ }
48
+ const signInResult = await thunderIDClient.signIn({
49
+ code,
50
+ session_state: sessionState,
51
+ state
52
+ }, {}, sessionId);
53
+ const config = await thunderIDClient.getConfiguration();
54
+ if (signInResult) try {
55
+ const idToken = await thunderIDClient.getDecodedIdToken(sessionId, signInResult["id_token"] || signInResult["idToken"]);
56
+ const accessToken = signInResult["accessToken"] || signInResult["access_token"];
57
+ const refreshToken = signInResult["refreshToken"] ?? "";
58
+ const userIdFromToken = idToken.sub || signInResult["sub"] || sessionId;
59
+ const scopes = signInResult["scope"];
60
+ const organizationId = idToken["user_org"] || idToken["organization_id"];
61
+ const expiresIn = signInResult["expiresIn"];
62
+ const sessionCookieExpiryTime = require_SessionManager.default.resolveSessionCookieExpiry(config.sessionCookie?.expiryTime);
63
+ const sessionToken = await require_SessionManager.default.createSessionToken(accessToken, userIdFromToken, sessionId, scopes, expiresIn, refreshToken, organizationId);
64
+ cookieStore.set(require_SessionManager.default.getSessionCookieName(), sessionToken, require_SessionManager.default.getSessionCookieOptions(sessionCookieExpiryTime));
65
+ cookieStore.delete(require_SessionManager.default.getTempSessionCookieName());
66
+ } catch (error) {
67
+ require_logger.default.error(`[handleOAuthCallbackAction] Failed to create JWT session, continuing with legacy session:
68
+ ${typeof error === "string" ? error : JSON.stringify(error)}`);
69
+ }
70
+ return {
71
+ redirectUrl: config.afterSignInUrl || "/",
72
+ success: true
73
+ };
74
+ } catch (error) {
75
+ let errorMessage = "Authentication failed";
76
+ if (error instanceof Error) errorMessage = error.message;
77
+ else if (error && typeof error === "object" && "message" in error) errorMessage = String(error.message);
78
+ else if (typeof error === "string") errorMessage = error;
79
+ return {
80
+ error: errorMessage,
81
+ success: false
82
+ };
83
+ }
84
+ };
85
+ var handleOAuthCallbackAction_default = handleOAuthCallbackAction;
86
+
87
+ //#endregion
88
+ exports.default = handleOAuthCallbackAction_default;
89
+ //# sourceMappingURL=handleOAuthCallbackAction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleOAuthCallbackAction.cjs","names":["getClient","cookieStore: RequestCookies","sessionId: string | undefined","tempSessionToken: string | undefined","SessionManager","signInResult: Record<string, unknown>","config: ThunderIDNextConfig","idToken: IdToken","accessToken: string","refreshToken: string","userIdFromToken: string","scopes: string","organizationId: string | undefined","expiresIn: number","sessionCookieExpiryTime: number","sessionToken: string"],"sources":["../../../../src/server/actions/handleOAuthCallbackAction.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\n'use server';\n\nimport {IdToken} from '@thunderid/node';\nimport {cookies} from 'next/headers';\nimport {ThunderIDNextConfig} from '../../models/config';\nimport logger from '../../utils/logger';\nimport SessionManager from '../../utils/SessionManager';\nimport getClient from '../getClient';\n\ntype RequestCookies = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Server action to handle OAuth callback with authorization code.\n * This action processes the authorization code received from the OAuth provider\n * and exchanges it for tokens to complete the authentication flow.\n *\n * @param code - Authorization code from OAuth provider\n * @param state - State parameter from OAuth provider for CSRF protection\n * @param sessionState - Session state parameter from OAuth provider\n * @returns Promise that resolves with success status and optional error message\n */\nconst handleOAuthCallbackAction = async (\n code: string,\n state: string,\n sessionState?: string,\n): Promise<{\n error?: string;\n redirectUrl?: string;\n success: boolean;\n}> => {\n try {\n if (!code || !state) {\n return {\n error: 'Missing required OAuth parameters: code and state are required',\n success: false,\n };\n }\n\n const thunderIDClient = getClient();\n\n if (!thunderIDClient.isInitialized) {\n return {\n error: 'ThunderID client is not initialized',\n success: false,\n };\n }\n\n const cookieStore: RequestCookies = await cookies();\n let sessionId: string | undefined;\n\n const tempSessionToken: string | undefined = cookieStore.get(SessionManager.getTempSessionCookieName())?.value;\n\n if (tempSessionToken) {\n try {\n const tempSession: {sessionId: string} = await SessionManager.verifyTempSession(tempSessionToken);\n sessionId = tempSession.sessionId;\n } catch {\n logger.error(\n '[handleOAuthCallbackAction] Invalid temporary session token, falling back to session ID from cookies.',\n );\n }\n }\n\n if (!sessionId) {\n logger.error('[handleOAuthCallbackAction] No session ID found in cookies or temporary session token.');\n\n return {\n error: 'No session found. Please start the authentication flow again.',\n success: false,\n };\n }\n\n // Exchange the authorization code for tokens\n const signInResult: Record<string, unknown> = await thunderIDClient.signIn(\n {\n code,\n session_state: sessionState,\n state,\n } as any,\n {},\n sessionId,\n );\n\n const config: ThunderIDNextConfig = await thunderIDClient.getConfiguration();\n\n if (signInResult) {\n try {\n const idToken: IdToken = await thunderIDClient.getDecodedIdToken(\n sessionId,\n (signInResult['id_token'] || signInResult['idToken']) as string,\n );\n const accessToken: string = (signInResult['accessToken'] || signInResult['access_token']) as string;\n const refreshToken: string = (signInResult['refreshToken'] as string | undefined) ?? '';\n const userIdFromToken: string = (idToken.sub || signInResult['sub'] || sessionId) as string;\n const scopes: string = signInResult['scope'] as string;\n const organizationId: string | undefined = (idToken['user_org'] || idToken['organization_id']) as\n | string\n | undefined;\n const expiresIn: number = signInResult['expiresIn'] as number;\n const sessionCookieExpiryTime: number = SessionManager.resolveSessionCookieExpiry(\n config.sessionCookie?.expiryTime,\n );\n\n const sessionToken: string = await SessionManager.createSessionToken(\n accessToken,\n userIdFromToken,\n sessionId,\n scopes,\n expiresIn,\n refreshToken,\n organizationId,\n );\n\n cookieStore.set(\n SessionManager.getSessionCookieName(),\n sessionToken,\n SessionManager.getSessionCookieOptions(sessionCookieExpiryTime),\n );\n\n cookieStore.delete(SessionManager.getTempSessionCookieName());\n } catch (error) {\n logger.error(\n `[handleOAuthCallbackAction] Failed to create JWT session, continuing with legacy session:\n ${typeof error === 'string' ? error : JSON.stringify(error)}`,\n );\n }\n }\n\n const afterSignInUrl: string = config.afterSignInUrl || '/';\n\n return {\n redirectUrl: afterSignInUrl,\n success: true,\n };\n } catch (error) {\n let errorMessage = 'Authentication failed';\n\n if (error instanceof Error) {\n errorMessage = error.message;\n } else if (error && typeof error === 'object' && 'message' in error) {\n errorMessage = String((error as {message: unknown}).message);\n } else if (typeof error === 'string') {\n errorMessage = error;\n }\n\n return {\n error: errorMessage,\n success: false,\n };\n }\n};\n\nexport default handleOAuthCallbackAction;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,4BAA4B,OAChC,MACA,OACA,iBAKI;AACJ,KAAI;AACF,MAAI,CAAC,QAAQ,CAAC,MACZ,QAAO;GACL,OAAO;GACP,SAAS;GACV;EAGH,MAAM,kBAAkBA,2BAAW;AAEnC,MAAI,CAAC,gBAAgB,cACnB,QAAO;GACL,OAAO;GACP,SAAS;GACV;EAGH,MAAMC,cAA8B,iCAAe;EACnD,IAAIC;EAEJ,MAAMC,mBAAuC,YAAY,IAAIC,+BAAe,0BAA0B,CAAC,EAAE;AAEzG,MAAI,iBACF,KAAI;AAEF,gBADyC,MAAMA,+BAAe,kBAAkB,iBAAiB,EACzE;UAClB;AACN,0BAAO,MACL,wGACD;;AAIL,MAAI,CAAC,WAAW;AACd,0BAAO,MAAM,yFAAyF;AAEtG,UAAO;IACL,OAAO;IACP,SAAS;IACV;;EAIH,MAAMC,eAAwC,MAAM,gBAAgB,OAClE;GACE;GACA,eAAe;GACf;GACD,EACD,EAAE,EACF,UACD;EAED,MAAMC,SAA8B,MAAM,gBAAgB,kBAAkB;AAE5E,MAAI,aACF,KAAI;GACF,MAAMC,UAAmB,MAAM,gBAAgB,kBAC7C,WACC,aAAa,eAAe,aAAa,WAC3C;GACD,MAAMC,cAAuB,aAAa,kBAAkB,aAAa;GACzE,MAAMC,eAAwB,aAAa,mBAA0C;GACrF,MAAMC,kBAA2B,QAAQ,OAAO,aAAa,UAAU;GACvE,MAAMC,SAAiB,aAAa;GACpC,MAAMC,iBAAsC,QAAQ,eAAe,QAAQ;GAG3E,MAAMC,YAAoB,aAAa;GACvC,MAAMC,0BAAkCV,+BAAe,2BACrD,OAAO,eAAe,WACvB;GAED,MAAMW,eAAuB,MAAMX,+BAAe,mBAChD,aACA,iBACA,WACA,QACA,WACA,cACA,eACD;AAED,eAAY,IACVA,+BAAe,sBAAsB,EACrC,cACAA,+BAAe,wBAAwB,wBAAwB,CAChE;AAED,eAAY,OAAOA,+BAAe,0BAA0B,CAAC;WACtD,OAAO;AACd,0BAAO,MACL;YACE,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,MAAM,GAC5D;;AAML,SAAO;GACL,aAH6B,OAAO,kBAAkB;GAItD,SAAS;GACV;UACM,OAAO;EACd,IAAI,eAAe;AAEnB,MAAI,iBAAiB,MACnB,gBAAe,MAAM;WACZ,SAAS,OAAO,UAAU,YAAY,aAAa,MAC5D,gBAAe,OAAQ,MAA6B,QAAQ;WACnD,OAAO,UAAU,SAC1B,gBAAe;AAGjB,SAAO;GACL,OAAO;GACP,SAAS;GACV;;;AAIL,wCAAe"}
@@ -0,0 +1,40 @@
1
+ 'use server';
2
+
3
+
4
+ const require_getSessionId = require('./getSessionId.cjs');
5
+ const require_getClient = require('../getClient.cjs');
6
+ const require_getSessionPayload = require('./getSessionPayload.cjs');
7
+
8
+ //#region src/server/actions/isSignedIn.ts
9
+ /**
10
+ * Check if the user is currently signed in.
11
+ *
12
+ * For JWT-based sessions: the session JWT exp claim is now tied to the access
13
+ * token expiry. A successful jwtVerify (inside getSessionPayload) already proves
14
+ * exp > now, so no separate timestamp comparison is needed here.
15
+ *
16
+ * Falls back to the legacy SDK in-memory check when no JWT session cookie exists.
17
+ *
18
+ * @param sessionId - Optional session ID (used only for the legacy fallback path)
19
+ * @returns True if the user is signed in with a valid, non-expired token
20
+ */
21
+ const isSignedIn = async (sessionId) => {
22
+ try {
23
+ if (await require_getSessionPayload.default()) return true;
24
+ const resolvedSessionId = sessionId || await require_getSessionId.default();
25
+ if (!resolvedSessionId) return false;
26
+ const client = require_getClient.default();
27
+ try {
28
+ return !!await client.getAccessToken(resolvedSessionId);
29
+ } catch {
30
+ return false;
31
+ }
32
+ } catch {
33
+ return false;
34
+ }
35
+ };
36
+ var isSignedIn_default = isSignedIn;
37
+
38
+ //#endregion
39
+ exports.default = isSignedIn_default;
40
+ //# sourceMappingURL=isSignedIn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSignedIn.cjs","names":["getSessionPayload","resolvedSessionId: string | undefined","getSessionId","getClient"],"sources":["../../../../src/server/actions/isSignedIn.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\n'use server';\n\nimport getSessionId from './getSessionId';\nimport getSessionPayload from './getSessionPayload';\nimport {SessionTokenPayload} from '../../utils/SessionManager';\nimport getClient from '../getClient';\n\n/**\n * Check if the user is currently signed in.\n *\n * For JWT-based sessions: the session JWT exp claim is now tied to the access\n * token expiry. A successful jwtVerify (inside getSessionPayload) already proves\n * exp > now, so no separate timestamp comparison is needed here.\n *\n * Falls back to the legacy SDK in-memory check when no JWT session cookie exists.\n *\n * @param sessionId - Optional session ID (used only for the legacy fallback path)\n * @returns True if the user is signed in with a valid, non-expired token\n */\nconst isSignedIn = async (sessionId?: string): Promise<boolean> => {\n try {\n const sessionPayload: SessionTokenPayload | undefined = await getSessionPayload();\n\n if (sessionPayload) {\n return true;\n }\n\n // No JWT session — fall back to the legacy SDK in-memory store check.\n const resolvedSessionId: string | undefined = sessionId || (await getSessionId());\n\n if (!resolvedSessionId) {\n return false;\n }\n\n const client = getClient();\n\n try {\n const accessToken: string = await client.getAccessToken(resolvedSessionId);\n return !!accessToken;\n } catch {\n return false;\n }\n } catch {\n return false;\n }\n};\n\nexport default isSignedIn;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,aAAa,OAAO,cAAyC;AACjE,KAAI;AAGF,MAFwD,MAAMA,mCAAmB,CAG/E,QAAO;EAIT,MAAMC,oBAAwC,aAAc,MAAMC,8BAAc;AAEhF,MAAI,CAAC,kBACH,QAAO;EAGT,MAAM,SAASC,2BAAW;AAE1B,MAAI;AAEF,UAAO,CAAC,CADoB,MAAM,OAAO,eAAe,kBAAkB;UAEpE;AACN,UAAO;;SAEH;AACN,SAAO;;;AAIX,yBAAe"}
@@ -0,0 +1,61 @@
1
+ 'use server';
2
+
3
+
4
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
5
+ const require_SessionManager = require('../../utils/SessionManager.cjs');
6
+ const require_getClient = require('../getClient.cjs');
7
+ const require_handleRefreshToken = require('../../utils/handleRefreshToken.cjs');
8
+ let __thunderid_node = require("@thunderid/node");
9
+ __thunderid_node = require_rolldown_runtime.__toESM(__thunderid_node);
10
+ let next_headers = require("next/headers");
11
+ next_headers = require_rolldown_runtime.__toESM(next_headers);
12
+
13
+ //#region src/server/actions/refreshToken.ts
14
+ /**
15
+ * Server action to refresh the access token using the stored refresh token.
16
+ * Exchanges the refresh token for a new token set and updates the session cookie.
17
+ *
18
+ * Delegates the HTTP exchange to handleRefreshToken so the same logic is shared
19
+ * with the middleware token refresh path.
20
+ *
21
+ * Called from the client side (e.g. ThunderIDClientProvider refreshOnMount) where
22
+ * Next.js allows cookie mutation. When invoked during SSR rendering the cookie
23
+ * write is silently skipped and a warning is logged.
24
+ */
25
+ const refreshToken = async () => {
26
+ try {
27
+ const cookieStore = await (0, next_headers.cookies)();
28
+ const sessionToken = cookieStore.get(require_SessionManager.default.getSessionCookieName())?.value;
29
+ if (!sessionToken) throw new __thunderid_node.ThunderIDAPIError("No active session found. User must be signed in to refresh the token.", "refreshToken-ServerActionError-002", "nextjs", 401);
30
+ const sessionPayload = await require_SessionManager.default.verifySessionTokenForRefresh(sessionToken);
31
+ const config = await require_getClient.default().getConfiguration();
32
+ const result = await require_handleRefreshToken.default(sessionPayload, {
33
+ baseUrl: config.baseUrl ?? "",
34
+ clientId: config.clientId ?? "",
35
+ clientSecret: config.clientSecret ?? "",
36
+ sessionCookie: config.sessionCookie
37
+ });
38
+ try {
39
+ cookieStore.set(require_SessionManager.default.getSessionCookieName(), result.newSessionToken, require_SessionManager.default.getSessionCookieOptions(result.sessionCookieExpiryTime));
40
+ } catch {
41
+ __thunderid_node.logger.warn("[refreshToken] Could not write session cookie — called from SSR rendering context.");
42
+ }
43
+ const rawExpiresIn = result.tokenResponse.expiresIn;
44
+ const expiresInSeconds = parseInt(rawExpiresIn ?? "", 10);
45
+ if (Number.isNaN(expiresInSeconds)) throw new Error(`[refreshToken] Invalid expiresIn value received: ${rawExpiresIn}`);
46
+ const expiresAt = Math.floor(Date.now() / 1e3) + expiresInSeconds;
47
+ __thunderid_node.logger.debug("[refreshToken] Token refresh succeeded.");
48
+ return { expiresAt };
49
+ } catch (error) {
50
+ try {
51
+ (await (0, next_headers.cookies)()).delete(require_SessionManager.default.getSessionCookieName());
52
+ __thunderid_node.logger.debug("[refreshToken] Cleared session cookie after refresh failure.");
53
+ } catch {}
54
+ throw new __thunderid_node.ThunderIDAPIError(`Failed to refresh the session: ${error instanceof Error ? error.message : JSON.stringify(error)}`, "refreshToken-ServerActionError-001", "nextjs", error instanceof __thunderid_node.ThunderIDAPIError ? error.statusCode : void 0);
55
+ }
56
+ };
57
+ var refreshToken_default = refreshToken;
58
+
59
+ //#endregion
60
+ exports.default = refreshToken_default;
61
+ //# sourceMappingURL=refreshToken.cjs.map