@thunderid/nextjs 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/ThunderIDNextClient.d.ts +0 -17
  2. package/dist/ThunderIDNextClient.d.ts.map +1 -1
  3. package/dist/ThunderIDNextClient.js.map +1 -1
  4. package/dist/cjs/ThunderIDNextClient.cjs.map +1 -1
  5. package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs.map +1 -1
  6. package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs.map +1 -1
  7. package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs.map +1 -1
  8. package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs.map +1 -1
  9. package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs.map +1 -1
  10. package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs.map +1 -1
  11. package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs.map +1 -1
  12. package/dist/cjs/client/components/presentation/User/User.cjs.map +1 -1
  13. package/dist/cjs/client/components/presentation/UserAvatar/UserAvatar.cjs.map +1 -1
  14. package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs.map +1 -1
  15. package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs.map +1 -1
  16. package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
  17. package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
  18. package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs.map +1 -1
  19. package/dist/cjs/constants/sessionConstants.cjs +0 -17
  20. package/dist/cjs/constants/sessionConstants.cjs.map +1 -1
  21. package/dist/cjs/server/ThunderIDProvider.cjs.map +1 -1
  22. package/dist/cjs/server/actions/clearSession.cjs.map +1 -1
  23. package/dist/cjs/server/actions/getAccessToken.cjs.map +1 -1
  24. package/dist/cjs/server/actions/getClientOrigin.cjs.map +1 -1
  25. package/dist/cjs/server/actions/getSessionId.cjs.map +1 -1
  26. package/dist/cjs/server/actions/getSessionPayload.cjs.map +1 -1
  27. package/dist/cjs/server/actions/getUserAction.cjs.map +1 -1
  28. package/dist/cjs/server/actions/getUserProfileAction.cjs.map +1 -1
  29. package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs.map +1 -1
  30. package/dist/cjs/server/actions/isSignedIn.cjs.map +1 -1
  31. package/dist/cjs/server/actions/refreshToken.cjs.map +1 -1
  32. package/dist/cjs/server/actions/signInAction.cjs.map +1 -1
  33. package/dist/cjs/server/actions/signOutAction.cjs.map +1 -1
  34. package/dist/cjs/server/actions/signUpAction.cjs.map +1 -1
  35. package/dist/cjs/server/actions/updateUserProfileAction.cjs.map +1 -1
  36. package/dist/cjs/server/getClient.cjs.map +1 -1
  37. package/dist/cjs/server/proxy/createRouteMatcher.cjs.map +1 -1
  38. package/dist/cjs/server/proxy/thunderIDProxy.cjs.map +1 -1
  39. package/dist/cjs/server/thunderid.cjs.map +1 -1
  40. package/dist/cjs/utils/SessionManager.cjs.map +1 -1
  41. package/dist/cjs/utils/decorateConfigWithNextEnv.cjs.map +1 -1
  42. package/dist/cjs/utils/handleRefreshToken.cjs.map +1 -1
  43. package/dist/cjs/utils/logger.cjs.map +1 -1
  44. package/dist/cjs/utils/sessionUtils.cjs.map +1 -1
  45. package/dist/client/components/actions/SignInButton/SignInButton.d.ts +0 -17
  46. package/dist/client/components/actions/SignInButton/SignInButton.d.ts.map +1 -1
  47. package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -1
  48. package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts +0 -17
  49. package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts.map +1 -1
  50. package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -1
  51. package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts +0 -17
  52. package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts.map +1 -1
  53. package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -1
  54. package/dist/client/components/control/Loading/Loading.d.ts +0 -17
  55. package/dist/client/components/control/Loading/Loading.d.ts.map +1 -1
  56. package/dist/client/components/control/SignedIn/SignedIn.d.ts +0 -17
  57. package/dist/client/components/control/SignedIn/SignedIn.d.ts.map +1 -1
  58. package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -1
  59. package/dist/client/components/control/SignedOut/SignedOut.d.ts +0 -17
  60. package/dist/client/components/control/SignedOut/SignedOut.d.ts.map +1 -1
  61. package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -1
  62. package/dist/client/components/presentation/SignIn/SignIn.d.ts +0 -17
  63. package/dist/client/components/presentation/SignIn/SignIn.d.ts.map +1 -1
  64. package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -1
  65. package/dist/client/components/presentation/SignUp/SignUp.d.ts +0 -17
  66. package/dist/client/components/presentation/SignUp/SignUp.d.ts.map +1 -1
  67. package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -1
  68. package/dist/client/components/presentation/User/User.d.ts +0 -17
  69. package/dist/client/components/presentation/User/User.d.ts.map +1 -1
  70. package/dist/client/components/presentation/User/User.js.map +1 -1
  71. package/dist/client/components/presentation/UserAvatar/UserAvatar.d.ts +0 -17
  72. package/dist/client/components/presentation/UserAvatar/UserAvatar.d.ts.map +1 -1
  73. package/dist/client/components/presentation/UserAvatar/UserAvatar.js.map +1 -1
  74. package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts +0 -17
  75. package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +1 -1
  76. package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -1
  77. package/dist/client/components/presentation/UserProfile/UserProfile.d.ts +0 -17
  78. package/dist/client/components/presentation/UserProfile/UserProfile.d.ts.map +1 -1
  79. package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -1
  80. package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts +0 -17
  81. package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
  82. package/dist/client/contexts/ThunderID/ThunderIDContext.js.map +1 -1
  83. package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts +0 -17
  84. package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
  85. package/dist/client/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
  86. package/dist/client/contexts/ThunderID/useThunderID.d.ts +0 -17
  87. package/dist/client/contexts/ThunderID/useThunderID.d.ts.map +1 -1
  88. package/dist/client/contexts/ThunderID/useThunderID.js.map +1 -1
  89. package/dist/client/index.d.ts +0 -17
  90. package/dist/client/index.d.ts.map +1 -1
  91. package/dist/configs/InternalAuthAPIRoutesConfig.d.ts +0 -17
  92. package/dist/configs/InternalAuthAPIRoutesConfig.d.ts.map +1 -1
  93. package/dist/constants/sessionConstants.d.ts +0 -17
  94. package/dist/constants/sessionConstants.d.ts.map +1 -1
  95. package/dist/constants/sessionConstants.js +0 -17
  96. package/dist/constants/sessionConstants.js.map +1 -1
  97. package/dist/index.d.ts +0 -17
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/models/api.d.ts +0 -17
  100. package/dist/models/api.d.ts.map +1 -1
  101. package/dist/models/config.d.ts +0 -17
  102. package/dist/models/config.d.ts.map +1 -1
  103. package/dist/server/ThunderIDProvider.d.ts +0 -17
  104. package/dist/server/ThunderIDProvider.d.ts.map +1 -1
  105. package/dist/server/ThunderIDProvider.js.map +1 -1
  106. package/dist/server/actions/clearSession.d.ts +0 -17
  107. package/dist/server/actions/clearSession.d.ts.map +1 -1
  108. package/dist/server/actions/clearSession.js.map +1 -1
  109. package/dist/server/actions/getAccessToken.d.ts +0 -17
  110. package/dist/server/actions/getAccessToken.d.ts.map +1 -1
  111. package/dist/server/actions/getAccessToken.js.map +1 -1
  112. package/dist/server/actions/getClientOrigin.d.ts +0 -17
  113. package/dist/server/actions/getClientOrigin.d.ts.map +1 -1
  114. package/dist/server/actions/getClientOrigin.js.map +1 -1
  115. package/dist/server/actions/getSessionId.d.ts +0 -17
  116. package/dist/server/actions/getSessionId.d.ts.map +1 -1
  117. package/dist/server/actions/getSessionId.js.map +1 -1
  118. package/dist/server/actions/getSessionPayload.d.ts +0 -17
  119. package/dist/server/actions/getSessionPayload.d.ts.map +1 -1
  120. package/dist/server/actions/getSessionPayload.js.map +1 -1
  121. package/dist/server/actions/getUserAction.d.ts +0 -17
  122. package/dist/server/actions/getUserAction.d.ts.map +1 -1
  123. package/dist/server/actions/getUserAction.js.map +1 -1
  124. package/dist/server/actions/getUserProfileAction.d.ts +0 -17
  125. package/dist/server/actions/getUserProfileAction.d.ts.map +1 -1
  126. package/dist/server/actions/getUserProfileAction.js.map +1 -1
  127. package/dist/server/actions/handleOAuthCallbackAction.d.ts +0 -17
  128. package/dist/server/actions/handleOAuthCallbackAction.d.ts.map +1 -1
  129. package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -1
  130. package/dist/server/actions/isSignedIn.d.ts +0 -17
  131. package/dist/server/actions/isSignedIn.d.ts.map +1 -1
  132. package/dist/server/actions/isSignedIn.js.map +1 -1
  133. package/dist/server/actions/refreshToken.d.ts +0 -17
  134. package/dist/server/actions/refreshToken.d.ts.map +1 -1
  135. package/dist/server/actions/refreshToken.js.map +1 -1
  136. package/dist/server/actions/signInAction.d.ts +0 -17
  137. package/dist/server/actions/signInAction.d.ts.map +1 -1
  138. package/dist/server/actions/signInAction.js.map +1 -1
  139. package/dist/server/actions/signOutAction.d.ts +0 -17
  140. package/dist/server/actions/signOutAction.d.ts.map +1 -1
  141. package/dist/server/actions/signOutAction.js.map +1 -1
  142. package/dist/server/actions/signUpAction.d.ts +0 -17
  143. package/dist/server/actions/signUpAction.d.ts.map +1 -1
  144. package/dist/server/actions/signUpAction.js.map +1 -1
  145. package/dist/server/actions/updateUserProfileAction.d.ts +0 -17
  146. package/dist/server/actions/updateUserProfileAction.d.ts.map +1 -1
  147. package/dist/server/actions/updateUserProfileAction.js.map +1 -1
  148. package/dist/server/getClient.d.ts +0 -17
  149. package/dist/server/getClient.d.ts.map +1 -1
  150. package/dist/server/getClient.js.map +1 -1
  151. package/dist/server/index.d.ts +0 -17
  152. package/dist/server/index.d.ts.map +1 -1
  153. package/dist/server/proxy/createRouteMatcher.d.ts +0 -17
  154. package/dist/server/proxy/createRouteMatcher.d.ts.map +1 -1
  155. package/dist/server/proxy/createRouteMatcher.js.map +1 -1
  156. package/dist/server/proxy/thunderIDProxy.d.ts +0 -17
  157. package/dist/server/proxy/thunderIDProxy.d.ts.map +1 -1
  158. package/dist/server/proxy/thunderIDProxy.js.map +1 -1
  159. package/dist/server/thunderid.d.ts +0 -17
  160. package/dist/server/thunderid.d.ts.map +1 -1
  161. package/dist/server/thunderid.js.map +1 -1
  162. package/dist/utils/SessionManager.d.ts +0 -17
  163. package/dist/utils/SessionManager.d.ts.map +1 -1
  164. package/dist/utils/SessionManager.js.map +1 -1
  165. package/dist/utils/createRouteMatcher.d.ts +0 -17
  166. package/dist/utils/createRouteMatcher.d.ts.map +1 -1
  167. package/dist/utils/decorateConfigWithNextEnv.d.ts +0 -17
  168. package/dist/utils/decorateConfigWithNextEnv.d.ts.map +1 -1
  169. package/dist/utils/decorateConfigWithNextEnv.js.map +1 -1
  170. package/dist/utils/handleRefreshToken.d.ts +0 -17
  171. package/dist/utils/handleRefreshToken.d.ts.map +1 -1
  172. package/dist/utils/handleRefreshToken.js.map +1 -1
  173. package/dist/utils/logger.d.ts +0 -17
  174. package/dist/utils/logger.d.ts.map +1 -1
  175. package/dist/utils/logger.js.map +1 -1
  176. package/dist/utils/sessionUtils.d.ts +0 -17
  177. package/dist/utils/sessionUtils.d.ts.map +1 -1
  178. package/dist/utils/sessionUtils.js.map +1 -1
  179. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"UserDropdown.js","names":["UserDropdown: FC<UserDropdownProps>","useThunderID","renderProps: UserDropdownRenderProps","UserProfile"],"sources":["../../../../../src/client/components/presentation/UserDropdown/UserDropdown.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 {BaseUserDropdown, BaseUserDropdownProps} from '@thunderid/react';\nimport {FC, ReactElement, ReactNode, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport UserProfile from '../UserProfile/UserProfile.js';\n\n/**\n * Render props data passed to the children function\n */\nexport interface UserDropdownRenderProps {\n /** Function to close the profile dialog */\n closeProfile: () => void;\n /** Whether user data is currently loading */\n isLoading: boolean;\n /** Whether the profile dialog is currently open */\n isProfileOpen: boolean;\n /** Function to open the user profile dialog */\n openProfile: () => void;\n /** Function to sign out the user */\n signOut: () => void;\n /** The authenticated user object */\n user: any;\n}\n\n/**\n * Props for the UserDropdown component.\n * Extends BaseUserDropdownProps but excludes user, onManageProfile, and onSignOut since they're handled internally\n */\nexport type UserDropdownProps = Omit<BaseUserDropdownProps, 'user' | 'onManageProfile'> & {\n /**\n * Render prop function that receives user state and actions.\n * When provided, this completely replaces the default dropdown rendering.\n */\n children?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the dropdown content.\n * When provided, this replaces just the dropdown content while keeping the trigger.\n */\n renderDropdown?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the trigger button.\n * When provided, this replaces just the trigger button while keeping the dropdown.\n */\n renderTrigger?: (props: UserDropdownRenderProps) => ReactNode;\n};\n\n/**\n * UserDropdown component displays a user avatar with a dropdown menu.\n * When clicked, it shows a popover with customizable menu items.\n * This component is the React-specific implementation that uses the BaseUserDropdown\n * and automatically retrieves the user data from ThunderID context.\n *\n * Supports render props for complete customization of the dropdown appearance and behavior.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserDropdown menuItems={[\n * { label: 'Profile', onClick: () => {} },\n * { label: 'Settings', href: '/settings' },\n * { label: 'Sign Out', onClick: () => {} }\n * ]} />\n *\n * // With custom configuration\n * <UserDropdown\n * showTriggerLabel={true}\n * avatarSize={40}\n * fallback={<div>Please sign in</div>}\n * />\n *\n * // Using render props for complete customization\n * <UserDropdown>\n * {({ user, isLoading, openProfile, signOut }) => (\n * <div>\n * <button onClick={openProfile}>\n * {user?.name || 'Loading...'}\n * </button>\n * <button onClick={signOut}>Logout</button>\n * </div>\n * )}\n * </UserDropdown>\n *\n * // Using partial render props\n * <UserDropdown\n * renderTrigger={({ user, openProfile }) => (\n * <button onClick={openProfile} className=\"custom-trigger\">\n * Welcome, {user?.name}!\n * </button>\n * )}\n * />\n * ```\n */\nconst UserDropdown: FC<UserDropdownProps> = ({\n children,\n renderTrigger,\n renderDropdown,\n onSignOut,\n ...rest\n}: UserDropdownProps): ReactElement => {\n const {user, isLoading, signOut} = useThunderID();\n const [isProfileOpen, setIsProfileOpen] = useState(false);\n\n const handleManageProfile = (): void => {\n setIsProfileOpen(true);\n };\n\n const handleSignOut = (): void => {\n signOut();\n if (onSignOut) {\n onSignOut();\n }\n };\n\n const closeProfile = (): void => {\n setIsProfileOpen(false);\n };\n\n // Prepare render props data\n const renderProps: UserDropdownRenderProps = {\n closeProfile,\n isLoading: isLoading!,\n isProfileOpen,\n openProfile: handleManageProfile,\n signOut: handleSignOut,\n user,\n };\n\n // If children render prop is provided, use it for complete customization\n if (children) {\n return (\n <>\n {children(renderProps)}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // If partial render props are provided, customize specific parts\n if (renderTrigger || renderDropdown) {\n // This would require significant changes to BaseUserDropdown to support partial customization\n // For now, we'll provide a simple implementation that shows how it could work\n return (\n <>\n {renderTrigger ? (\n renderTrigger(renderProps)\n ) : (\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n )}\n {/* Note: renderDropdown would need BaseUserDropdown modifications to implement properly */}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // Default behavior - use BaseUserDropdown as before\n return (\n <>\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n {isProfileOpen && <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />}\n </>\n );\n};\n\nexport default UserDropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,MAAMA,gBAAuC,EAC3C,UACA,eACA,gBACA,UACA,GAAG,WACkC;CACrC,MAAM,EAAC,MAAM,WAAW,YAAWC,sBAAc;CACjD,MAAM,CAAC,eAAe,oBAAoB,SAAS,MAAM;CAEzD,MAAM,4BAAkC;AACtC,mBAAiB,KAAK;;CAGxB,MAAM,sBAA4B;AAChC,WAAS;AACT,MAAI,UACF,YAAW;;CAIf,MAAM,qBAA2B;AAC/B,mBAAiB,MAAM;;CAIzB,MAAMC,cAAuC;EAC3C;EACW;EACX;EACA,aAAa;EACb,SAAS;EACT;EACD;AAGD,KAAI,SACF,QACE,4CACG,SAAS,YAAY,EACtB,oBAACC;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,KAAI,iBAAiB,eAGnB,QACE,4CACG,gBACC,cAAc,YAAY,GAE1B,oBAAC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EAGJ,oBAACA;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,QACE,4CACE,oBAAC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EACD,iBAAiB,oBAACA;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAClG;;AAIP,2BAAe"}
1
+ {"version":3,"file":"UserDropdown.js","names":["UserDropdown: FC<UserDropdownProps>","useThunderID","renderProps: UserDropdownRenderProps","UserProfile"],"sources":["../../../../../src/client/components/presentation/UserDropdown/UserDropdown.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {BaseUserDropdown, BaseUserDropdownProps} from '@thunderid/react';\nimport {FC, ReactElement, ReactNode, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport UserProfile from '../UserProfile/UserProfile.js';\n\n/**\n * Render props data passed to the children function\n */\nexport interface UserDropdownRenderProps {\n /** Function to close the profile dialog */\n closeProfile: () => void;\n /** Whether user data is currently loading */\n isLoading: boolean;\n /** Whether the profile dialog is currently open */\n isProfileOpen: boolean;\n /** Function to open the user profile dialog */\n openProfile: () => void;\n /** Function to sign out the user */\n signOut: () => void;\n /** The authenticated user object */\n user: any;\n}\n\n/**\n * Props for the UserDropdown component.\n * Extends BaseUserDropdownProps but excludes user, onManageProfile, and onSignOut since they're handled internally\n */\nexport type UserDropdownProps = Omit<BaseUserDropdownProps, 'user' | 'onManageProfile'> & {\n /**\n * Render prop function that receives user state and actions.\n * When provided, this completely replaces the default dropdown rendering.\n */\n children?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the dropdown content.\n * When provided, this replaces just the dropdown content while keeping the trigger.\n */\n renderDropdown?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the trigger button.\n * When provided, this replaces just the trigger button while keeping the dropdown.\n */\n renderTrigger?: (props: UserDropdownRenderProps) => ReactNode;\n};\n\n/**\n * UserDropdown component displays a user avatar with a dropdown menu.\n * When clicked, it shows a popover with customizable menu items.\n * This component is the React-specific implementation that uses the BaseUserDropdown\n * and automatically retrieves the user data from ThunderID context.\n *\n * Supports render props for complete customization of the dropdown appearance and behavior.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserDropdown menuItems={[\n * { label: 'Profile', onClick: () => {} },\n * { label: 'Settings', href: '/settings' },\n * { label: 'Sign Out', onClick: () => {} }\n * ]} />\n *\n * // With custom configuration\n * <UserDropdown\n * showTriggerLabel={true}\n * avatarSize={40}\n * fallback={<div>Please sign in</div>}\n * />\n *\n * // Using render props for complete customization\n * <UserDropdown>\n * {({ user, isLoading, openProfile, signOut }) => (\n * <div>\n * <button onClick={openProfile}>\n * {user?.name || 'Loading...'}\n * </button>\n * <button onClick={signOut}>Logout</button>\n * </div>\n * )}\n * </UserDropdown>\n *\n * // Using partial render props\n * <UserDropdown\n * renderTrigger={({ user, openProfile }) => (\n * <button onClick={openProfile} className=\"custom-trigger\">\n * Welcome, {user?.name}!\n * </button>\n * )}\n * />\n * ```\n */\nconst UserDropdown: FC<UserDropdownProps> = ({\n children,\n renderTrigger,\n renderDropdown,\n onSignOut,\n ...rest\n}: UserDropdownProps): ReactElement => {\n const {user, isLoading, signOut} = useThunderID();\n const [isProfileOpen, setIsProfileOpen] = useState(false);\n\n const handleManageProfile = (): void => {\n setIsProfileOpen(true);\n };\n\n const handleSignOut = (): void => {\n signOut();\n if (onSignOut) {\n onSignOut();\n }\n };\n\n const closeProfile = (): void => {\n setIsProfileOpen(false);\n };\n\n // Prepare render props data\n const renderProps: UserDropdownRenderProps = {\n closeProfile,\n isLoading: isLoading!,\n isProfileOpen,\n openProfile: handleManageProfile,\n signOut: handleSignOut,\n user,\n };\n\n // If children render prop is provided, use it for complete customization\n if (children) {\n return (\n <>\n {children(renderProps)}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // If partial render props are provided, customize specific parts\n if (renderTrigger || renderDropdown) {\n // This would require significant changes to BaseUserDropdown to support partial customization\n // For now, we'll provide a simple implementation that shows how it could work\n return (\n <>\n {renderTrigger ? (\n renderTrigger(renderProps)\n ) : (\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n )}\n {/* Note: renderDropdown would need BaseUserDropdown modifications to implement properly */}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // Default behavior - use BaseUserDropdown as before\n return (\n <>\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n {isProfileOpen && <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />}\n </>\n );\n};\n\nexport default UserDropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAMA,gBAAuC,EAC3C,UACA,eACA,gBACA,UACA,GAAG,WACkC;CACrC,MAAM,EAAC,MAAM,WAAW,YAAWC,sBAAc;CACjD,MAAM,CAAC,eAAe,oBAAoB,SAAS,MAAM;CAEzD,MAAM,4BAAkC;AACtC,mBAAiB,KAAK;;CAGxB,MAAM,sBAA4B;AAChC,WAAS;AACT,MAAI,UACF,YAAW;;CAIf,MAAM,qBAA2B;AAC/B,mBAAiB,MAAM;;CAIzB,MAAMC,cAAuC;EAC3C;EACW;EACX;EACA,aAAa;EACb,SAAS;EACT;EACD;AAGD,KAAI,SACF,QACE,4CACG,SAAS,YAAY,EACtB,oBAACC;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,KAAI,iBAAiB,eAGnB,QACE,4CACG,gBACC,cAAc,YAAY,GAE1B,oBAAC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EAGJ,oBAACA;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,QACE,4CACE,oBAAC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EACD,iBAAiB,oBAACA;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAClG;;AAIP,2BAAe"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { BaseUserProfileProps } from '@thunderid/react';
19
2
  import { FC } from 'react';
20
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"UserProfile.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAkB,oBAAoB,EAA0B,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAC,EAAE,EAAyB,MAAM,OAAO,CAAC;AAIjD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CAAC,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAkDrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"UserProfile.d.ts","sourceRoot":"","sources":["../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAkB,oBAAoB,EAA0B,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAC,EAAE,EAAyB,MAAM,OAAO,CAAC;AAIjD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CAAC,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAkDrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"UserProfile.js","names":["UserProfile: FC<UserProfileProps>","useThunderID","isEditableProfile: boolean","result: {data: {user: User}; error: string; success: boolean}","getSessionId"],"sources":["../../../../../src/client/components/presentation/UserProfile/UserProfile.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 {deepMerge, User} from '@thunderid/node';\nimport {BaseUserProfile, BaseUserProfileProps, useUser, useTranslation} from '@thunderid/react';\nimport {FC, ReactElement, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport getSessionId from '../../../../server/actions/getSessionId';\n\n/**\n * Props for the UserProfile component.\n * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile'>;\n\n/**\n * UserProfile component displays the authenticated user's profile information in a\n * structured and styled format. It shows user details such as display name, email,\n * username, and other available profile information from ThunderID.\n *\n * This component is the React-specific implementation that uses the BaseUserProfile\n * and automatically retrieves the user data from ThunderID context if not provided.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserProfile />\n *\n * // With explicit user data\n * <UserProfile user={specificUser} />\n *\n * // With card layout and custom fallback\n * <UserProfile\n * cardLayout={true}\n * fallback={<div>Please sign in to view your profile</div>}\n * />\n * ```\n */\nconst UserProfile: FC<UserProfileProps> = ({preferences, editable = true, ...rest}: UserProfileProps): ReactElement => {\n const {preferences: contextPreferences} = useThunderID();\n const {profile, flattenedProfile, onUpdateProfile, updateProfile} = useUser();\n const resolvedPreferences = {\n ...contextPreferences,\n ...preferences,\n user: {\n ...contextPreferences?.user,\n ...preferences?.user,\n },\n };\n const {t} = useTranslation(resolvedPreferences?.i18n);\n const isEditableProfile: boolean = resolvedPreferences?.user?.fetchUserProfile === false ? false : editable;\n\n const [error, setError] = useState<string | null>(null);\n\n const handleProfileUpdate = async (payload: any): Promise<void> => {\n setError(null);\n\n const updatedAttributes = deepMerge((profile?.['attributes'] as Record<string, unknown>) ?? {}, payload);\n\n Object.keys(updatedAttributes).forEach((key) => {\n if (updatedAttributes[key] === undefined || updatedAttributes[key] === null) {\n delete updatedAttributes[key];\n }\n });\n\n const result: {data: {user: User}; error: string; success: boolean} = await updateProfile(\n {payload: updatedAttributes},\n await getSessionId(),\n );\n\n if (result.success) {\n onUpdateProfile(result.data.user);\n } else {\n setError(result.error || t('user.profile.update.generic.error'));\n }\n };\n\n return (\n <BaseUserProfile\n profile={profile!}\n flattenedProfile={flattenedProfile!}\n editable={isEditableProfile}\n onUpdate={isEditableProfile ? handleProfileUpdate : undefined}\n error={error}\n preferences={resolvedPreferences}\n {...rest}\n />\n );\n};\n\nexport default UserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAMA,eAAqC,EAAC,aAAa,WAAW,KAAM,GAAG,WAA0C;CACrH,MAAM,EAAC,aAAa,uBAAsBC,sBAAc;CACxD,MAAM,EAAC,SAAS,kBAAkB,iBAAiB,kBAAiB,SAAS;CAC7E,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;EACH,MAAM;GACJ,GAAG,oBAAoB;GACvB,GAAG,aAAa;GACjB;EACF;CACD,MAAM,EAAC,MAAK,eAAe,qBAAqB,KAAK;CACrD,MAAMC,oBAA6B,qBAAqB,MAAM,qBAAqB,QAAQ,QAAQ;CAEnG,MAAM,CAAC,OAAO,YAAY,SAAwB,KAAK;CAEvD,MAAM,sBAAsB,OAAO,YAAgC;AACjE,WAAS,KAAK;EAEd,MAAM,oBAAoB,UAAW,UAAU,iBAA6C,EAAE,EAAE,QAAQ;AAExG,SAAO,KAAK,kBAAkB,CAAC,SAAS,QAAQ;AAC9C,OAAI,kBAAkB,SAAS,UAAa,kBAAkB,SAAS,KACrE,QAAO,kBAAkB;IAE3B;EAEF,MAAMC,SAAgE,MAAM,cAC1E,EAAC,SAAS,mBAAkB,EAC5B,MAAMC,sBAAc,CACrB;AAED,MAAI,OAAO,QACT,iBAAgB,OAAO,KAAK,KAAK;MAEjC,UAAS,OAAO,SAAS,EAAE,oCAAoC,CAAC;;AAIpE,QACE,oBAAC;EACU;EACS;EAClB,UAAU;EACV,UAAU,oBAAoB,sBAAsB;EAC7C;EACP,aAAa;EACb,GAAI;GACJ;;AAIN,0BAAe"}
1
+ {"version":3,"file":"UserProfile.js","names":["UserProfile: FC<UserProfileProps>","useThunderID","isEditableProfile: boolean","result: {data: {user: User}; error: string; success: boolean}","getSessionId"],"sources":["../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {deepMerge, User} from '@thunderid/node';\nimport {BaseUserProfile, BaseUserProfileProps, useUser, useTranslation} from '@thunderid/react';\nimport {FC, ReactElement, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport getSessionId from '../../../../server/actions/getSessionId';\n\n/**\n * Props for the UserProfile component.\n * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile'>;\n\n/**\n * UserProfile component displays the authenticated user's profile information in a\n * structured and styled format. It shows user details such as display name, email,\n * username, and other available profile information from ThunderID.\n *\n * This component is the React-specific implementation that uses the BaseUserProfile\n * and automatically retrieves the user data from ThunderID context if not provided.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserProfile />\n *\n * // With explicit user data\n * <UserProfile user={specificUser} />\n *\n * // With card layout and custom fallback\n * <UserProfile\n * cardLayout={true}\n * fallback={<div>Please sign in to view your profile</div>}\n * />\n * ```\n */\nconst UserProfile: FC<UserProfileProps> = ({preferences, editable = true, ...rest}: UserProfileProps): ReactElement => {\n const {preferences: contextPreferences} = useThunderID();\n const {profile, flattenedProfile, onUpdateProfile, updateProfile} = useUser();\n const resolvedPreferences = {\n ...contextPreferences,\n ...preferences,\n user: {\n ...contextPreferences?.user,\n ...preferences?.user,\n },\n };\n const {t} = useTranslation(resolvedPreferences?.i18n);\n const isEditableProfile: boolean = resolvedPreferences?.user?.fetchUserProfile === false ? false : editable;\n\n const [error, setError] = useState<string | null>(null);\n\n const handleProfileUpdate = async (payload: any): Promise<void> => {\n setError(null);\n\n const updatedAttributes = deepMerge((profile?.['attributes'] as Record<string, unknown>) ?? {}, payload);\n\n Object.keys(updatedAttributes).forEach((key) => {\n if (updatedAttributes[key] === undefined || updatedAttributes[key] === null) {\n delete updatedAttributes[key];\n }\n });\n\n const result: {data: {user: User}; error: string; success: boolean} = await updateProfile(\n {payload: updatedAttributes},\n await getSessionId(),\n );\n\n if (result.success) {\n onUpdateProfile(result.data.user);\n } else {\n setError(result.error || t('user.profile.update.generic.error'));\n }\n };\n\n return (\n <BaseUserProfile\n profile={profile!}\n flattenedProfile={flattenedProfile!}\n editable={isEditableProfile}\n onUpdate={isEditableProfile ? handleProfileUpdate : undefined}\n error={error}\n preferences={resolvedPreferences}\n {...rest}\n />\n );\n};\n\nexport default UserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,eAAqC,EAAC,aAAa,WAAW,KAAM,GAAG,WAA0C;CACrH,MAAM,EAAC,aAAa,uBAAsBC,sBAAc;CACxD,MAAM,EAAC,SAAS,kBAAkB,iBAAiB,kBAAiB,SAAS;CAC7E,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;EACH,MAAM;GACJ,GAAG,oBAAoB;GACvB,GAAG,aAAa;GACjB;EACF;CACD,MAAM,EAAC,MAAK,eAAe,qBAAqB,KAAK;CACrD,MAAMC,oBAA6B,qBAAqB,MAAM,qBAAqB,QAAQ,QAAQ;CAEnG,MAAM,CAAC,OAAO,YAAY,SAAwB,KAAK;CAEvD,MAAM,sBAAsB,OAAO,YAAgC;AACjE,WAAS,KAAK;EAEd,MAAM,oBAAoB,UAAW,UAAU,iBAA6C,EAAE,EAAE,QAAQ;AAExG,SAAO,KAAK,kBAAkB,CAAC,SAAS,QAAQ;AAC9C,OAAI,kBAAkB,SAAS,UAAa,kBAAkB,SAAS,KACrE,QAAO,kBAAkB;IAE3B;EAEF,MAAMC,SAAgE,MAAM,cAC1E,EAAC,SAAS,mBAAkB,EAC5B,MAAMC,sBAAc,CACrB;AAED,MAAI,OAAO,QACT,iBAAgB,OAAO,KAAK,KAAK;MAEjC,UAAS,OAAO,SAAS,EAAE,oCAAoC,CAAC;;AAIpE,QACE,oBAAC;EACU;EACS;EAClB,UAAU;EACV,UAAU,oBAAoB,sBAAsB;EAC7C;EACP,aAAa;EACb,GAAI;GACJ;;AAIN,0BAAe"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { ThunderIDContextProps as ReactContextProps } from '@thunderid/react';
19
2
  import { Context } from 'react';
20
3
  import { RefreshResult } from '../../../server/actions/refreshToken';
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDContext.d.ts","sourceRoot":"","sources":["../../../../src/client/contexts/ThunderID/ThunderIDContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAC,qBAAqB,IAAI,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAC,OAAO,EAAgB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,sCAAsC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG;IAC/D,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAgB1D,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ThunderIDContext.d.ts","sourceRoot":"","sources":["../../../../src/client/contexts/ThunderID/ThunderIDContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,qBAAqB,IAAI,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAC,OAAO,EAAgB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,sCAAsC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG;IAC/D,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,gBAAgB,EAAE,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAgB1D,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDContext.js","names":["ThunderIDContext: Context<ThunderIDContextProps | null>"],"sources":["../../../../src/client/contexts/ThunderID/ThunderIDContext.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 client';\n\nimport {ThunderIDContextProps as ReactContextProps} from '@thunderid/react';\nimport {Context, createContext} from 'react';\nimport {RefreshResult} from '../../../server/actions/refreshToken';\n\n/**\n * Props interface of {@link ThunderIDContext}\n */\nexport type ThunderIDContextProps = Partial<ReactContextProps> & {\n clearSession?: () => Promise<void>;\n refreshToken?: () => Promise<RefreshResult>;\n};\n\n/**\n * Context object for managing the Authentication flow builder core context.\n */\nconst ThunderIDContext: Context<ThunderIDContextProps | null> = createContext<null | ThunderIDContextProps>({\n afterSignInUrl: undefined,\n applicationId: undefined,\n baseUrl: undefined,\n clearSession: () => Promise.resolve(),\n isInitialized: false,\n isLoading: true,\n isSignedIn: false,\n organizationHandle: undefined,\n refreshToken: () => Promise.resolve({expiresAt: 0}),\n signIn: () => Promise.resolve({} as any),\n signInUrl: undefined,\n signOut: () => Promise.resolve({} as any),\n signUp: () => Promise.resolve({} as any),\n signUpUrl: undefined,\n user: null,\n});\n\nThunderIDContext.displayName = 'ThunderIDContext';\n\nexport default ThunderIDContext;\n"],"mappings":";;;;;;;;;AAmCA,MAAMA,mBAA0D,cAA4C;CAC1G,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,oBAAoB,QAAQ,SAAS;CACrC,eAAe;CACf,WAAW;CACX,YAAY;CACZ,oBAAoB;CACpB,oBAAoB,QAAQ,QAAQ,EAAC,WAAW,GAAE,CAAC;CACnD,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,MAAM;CACP,CAAC;AAEF,iBAAiB,cAAc;AAE/B,+BAAe"}
1
+ {"version":3,"file":"ThunderIDContext.js","names":["ThunderIDContext: Context<ThunderIDContextProps | null>"],"sources":["../../../../src/client/contexts/ThunderID/ThunderIDContext.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {ThunderIDContextProps as ReactContextProps} from '@thunderid/react';\nimport {Context, createContext} from 'react';\nimport {RefreshResult} from '../../../server/actions/refreshToken';\n\n/**\n * Props interface of {@link ThunderIDContext}\n */\nexport type ThunderIDContextProps = Partial<ReactContextProps> & {\n clearSession?: () => Promise<void>;\n refreshToken?: () => Promise<RefreshResult>;\n};\n\n/**\n * Context object for managing the Authentication flow builder core context.\n */\nconst ThunderIDContext: Context<ThunderIDContextProps | null> = createContext<null | ThunderIDContextProps>({\n afterSignInUrl: undefined,\n applicationId: undefined,\n baseUrl: undefined,\n clearSession: () => Promise.resolve(),\n isInitialized: false,\n isLoading: true,\n isSignedIn: false,\n organizationHandle: undefined,\n refreshToken: () => Promise.resolve({expiresAt: 0}),\n signIn: () => Promise.resolve({} as any),\n signInUrl: undefined,\n signOut: () => Promise.resolve({} as any),\n signUp: () => Promise.resolve({} as any),\n signUpUrl: undefined,\n user: null,\n});\n\nThunderIDContext.displayName = 'ThunderIDContext';\n\nexport default ThunderIDContext;\n"],"mappings":";;;;;;;;;AAoBA,MAAMA,mBAA0D,cAA4C;CAC1G,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,oBAAoB,QAAQ,SAAS;CACrC,eAAe;CACf,WAAW;CACX,YAAY;CACZ,oBAAoB;CACpB,oBAAoB,QAAQ,QAAQ,EAAC,WAAW,GAAE,CAAC;CACnD,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,MAAM;CACP,CAAC;AAEF,iBAAiB,cAAc;AAE/B,+BAAe"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { FlowMetadataResponse, UpdateMeProfileConfig, User, UserProfile } from '@thunderid/node';
19
2
  import { ThunderIDProviderProps } from '@thunderid/react';
20
3
  import { FC, PropsWithChildren } from 'react';
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/cont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,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,KAClB,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC;IACvE;;;OAGG;IACH,WAAW,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxC,aAAa,EAAE,CACb,aAAa,EAAE,qBAAqB,EACpC,SAAS,CAAC,EAAE,MAAM,KACf,OAAO,CAAC;QAAC,IAAI,EAAE;YAAC,IAAI,EAAE,IAAI,CAAA;SAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC;IACpE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEJ,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CA2UhF,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDProvider.js","names":["ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps>>","reRenderCheckRef: RefObject<boolean>","router: AppRouterInstance","searchParams: ReadonlyURLSearchParams","code: string | null","state: string | null","sessionState: string | null","result: {error?: string; redirectUrl?: string; success: boolean}","result: any","contextValue: ThunderIDContextProps","reactContextValue: ReactThunderIDContextProps","ThunderIDContext","ReactThunderIDContext"],"sources":["../../../../src/client/contexts/ThunderID/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 client';\n\nimport {\n EmbeddedFlowExecuteRequestConfig,\n FlowMetadataResponse,\n generateFlattenedUserProfile,\n UpdateMeProfileConfig,\n User,\n UserProfile,\n ThunderIDRuntimeError,\n getVendorPrefix,\n} from '@thunderid/node';\nimport {\n I18nProvider,\n FlowMetaProvider,\n FlowProvider,\n UserProvider,\n ThemeProvider,\n ThunderIDContext as ReactThunderIDContext,\n ThunderIDContextProps as ReactThunderIDContextProps,\n ThunderIDProviderProps,\n getActiveTheme,\n} from '@thunderid/react';\nimport {ReadonlyURLSearchParams} from 'next/dist/client/components/navigation.react-server';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter, useSearchParams} from 'next/navigation';\nimport {FC, PropsWithChildren, RefObject, useEffect, useMemo, useRef, useState} from 'react';\nimport ThunderIDContext, {ThunderIDContextProps} from './ThunderIDContext';\nimport {RefreshResult} from '../../../server/actions/refreshToken';\nimport logger from '../../../utils/logger';\n\n/**\n * Props interface of {@link ThunderIDClientProvider}\n */\nexport type ThunderIDClientProviderProps = Partial<Omit<ThunderIDProviderProps, 'baseUrl' | 'clientId'>> &\n Pick<ThunderIDProviderProps, 'baseUrl' | 'clientId'> & {\n applicationId: ThunderIDContextProps['applicationId'];\n clearSession: () => Promise<void>;\n handleOAuthCallback: (\n code: string,\n state: string,\n sessionState?: string,\n ) => Promise<{error?: string; redirectUrl?: string; success: boolean}>;\n /**\n * Flow metadata fetched server-side ahead of time, seeding `FlowMetaProvider` so it can skip\n * its own initial client-side fetch (avoiding a flash of untranslated i18n keys).\n */\n initialMeta?: FlowMetadataResponse | null;\n isSignedIn: boolean;\n organizationHandle: ThunderIDContextProps['organizationHandle'];\n refreshToken: () => Promise<RefreshResult>;\n signIn: ThunderIDContextProps['signIn'];\n signOut: ThunderIDContextProps['signOut'];\n signUp: ThunderIDContextProps['signUp'];\n updateProfile: (\n requestConfig: UpdateMeProfileConfig,\n sessionId?: string,\n ) => Promise<{data: {user: User}; error: string; success: boolean}>;\n user: User | null;\n userProfile: UserProfile;\n };\n\nconst ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps>> = ({\n baseUrl,\n children,\n signIn,\n clearSession,\n refreshToken,\n signOut,\n signUp,\n handleOAuthCallback,\n preferences,\n isSignedIn,\n signInUrl,\n signUpUrl,\n user: _user,\n userProfile: _userProfile,\n updateProfile,\n applicationId,\n organizationHandle,\n scopes,\n vendor,\n initialMeta = null,\n}: PropsWithChildren<ThunderIDClientProviderProps>) => {\n const reRenderCheckRef: RefObject<boolean> = useRef(false);\n const router: AppRouterInstance = useRouter();\n const searchParams: ReadonlyURLSearchParams = useSearchParams();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [user, setUser] = useState<User | null>(_user);\n const [userProfile, setUserProfile] = useState<UserProfile>(_userProfile);\n\n useEffect(() => {\n setUserProfile(_userProfile);\n }, [_userProfile]);\n\n useEffect(() => {\n setUser(_user);\n }, [_user]);\n\n // Handle OAuth callback automatically\n useEffect(() => {\n // React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.\n // https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state\n // This will remount all the useEffects to ensure that there are no unexpected side effects.\n // When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to\n // prevent the re-render of this hook as suggested in the following discussion.\n // https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623\n if (reRenderCheckRef.current) {\n return;\n }\n\n reRenderCheckRef.current = true;\n\n // Don't handle callback if already signed in\n if (isSignedIn) return;\n\n (async (): Promise<void> => {\n try {\n const code: string | null = searchParams.get('code');\n const state: string | null = searchParams.get('state');\n const sessionState: string | null = searchParams.get('session_state');\n const error: string | null = searchParams.get('error');\n\n // Check for OAuth errors first\n if (error) {\n logger.error('[ThunderIDClientProvider] An error was received for the initiated sign-in request.');\n\n return;\n }\n\n // Handle OAuth callback if code and state are present\n if (code && state) {\n setIsLoading(true);\n\n const result: {error?: string; redirectUrl?: string; success: boolean} = await handleOAuthCallback(\n code,\n state,\n sessionState || undefined,\n );\n\n if (result.success) {\n // Redirect to the success URL\n if (result.redirectUrl) {\n router.push(result.redirectUrl);\n } else {\n // Refresh the page to update authentication state\n window.location.reload();\n }\n } else {\n logger.error(\n `[ThunderIDClientProvider] An error occurred while signing in: ${result.error || 'Authentication failed'}`,\n );\n }\n }\n } catch (error) {\n logger.error('[ThunderIDClientProvider] Failed to handle OAuth callback:', error);\n }\n })();\n }, []);\n\n useEffect(() => {\n // Set loading to false when server has resolved authentication state\n setIsLoading(false);\n }, [isSignedIn, user]);\n\n const handleSignIn = async (payload: any, request: EmbeddedFlowExecuteRequestConfig): Promise<any> => {\n if (!signIn) {\n throw new ThunderIDRuntimeError(\n '`signIn` function is not available.',\n 'ThunderIDClientProvider-handleSignIn-RuntimeError-001',\n 'nextjs',\n );\n }\n\n const result: any = await signIn(payload, request);\n\n // Redirect based flow URL is sent as `signInUrl` in the response.\n // Use window.location.href instead of router.push() — the OAuth authorization\n // endpoint is on an external server, and router.push() would send RSC fetch\n // headers that the identity provider doesn't understand, causing a CORS error.\n if (result?.data?.signInUrl) {\n window.location.href = result.data.signInUrl;\n\n return undefined;\n }\n\n // After the Embedded flow is successful, the URL to navigate next is sent as `afterSignInUrl` in the response.\n if (result?.data?.afterSignInUrl) {\n router.push(result.data.afterSignInUrl);\n\n return undefined;\n }\n\n if (result?.error) {\n throw new Error(result.error);\n }\n\n return result?.data ?? result;\n };\n\n const handleSignUp = async (payload: any, request: EmbeddedFlowExecuteRequestConfig): Promise<any> => {\n if (!signUp) {\n throw new ThunderIDRuntimeError(\n '`signUp` function is not available.',\n 'ThunderIDClientProvider-handleSignUp-RuntimeError-001',\n 'nextjs',\n );\n }\n\n const result: any = await signUp(payload, request);\n\n // Redirect based flow URL is sent as `signUpUrl` in the response.\n if (result?.data?.signUpUrl) {\n router.push(result.data.signUpUrl);\n\n return undefined;\n }\n\n // After the Embedded flow is successful, the URL to navigate next is sent as `afterSignUpUrl` in the response.\n if (result?.data?.afterSignUpUrl) {\n router.push(result.data.afterSignUpUrl);\n\n return undefined;\n }\n\n if (result?.error) {\n throw new Error(result.error);\n }\n\n return result?.data ?? result;\n };\n\n const handleSignOut = async (): Promise<any> => {\n logger.debug('[ThunderIDClientProvider][handleSignOut] `handleSignOut` called.');\n\n try {\n const result: any = await signOut();\n\n logger.debug('[ThunderIDClientProvider][handleSignOut] Sign out result:', result);\n\n if (result?.data?.afterSignOutUrl) {\n router.push(result.data.afterSignOutUrl);\n\n return {location: result.data.afterSignOutUrl, redirected: true};\n }\n\n if (result?.error) {\n logger.error(\n '[ThunderIDClientProvider][handleSignOut] Error result was returned during signing the user out with a button click:',\n result.error,\n );\n }\n\n return result?.data ?? result;\n } catch (error) {\n logger.error(\n '[ThunderIDClientProvider][handleSignOut] Error occurred during signing the user out with a button click:',\n error,\n );\n\n return undefined;\n }\n };\n\n const contextValue: ThunderIDContextProps = useMemo(\n () => ({\n applicationId,\n baseUrl,\n clearSession,\n isLoading,\n isSignedIn,\n organizationHandle,\n preferences,\n refreshToken,\n scopes,\n signIn: handleSignIn,\n signInUrl,\n signOut: handleSignOut,\n signUp: handleSignUp,\n signUpUrl,\n user,\n }),\n [\n baseUrl,\n user,\n isSignedIn,\n isLoading,\n signInUrl,\n signUpUrl,\n applicationId,\n organizationHandle,\n scopes,\n preferences,\n ],\n );\n\n const handleProfileUpdate = (payload: User): void => {\n setUser(payload);\n setUserProfile((prev: UserProfile) => ({\n ...prev,\n flattenedProfile: generateFlattenedUserProfile(payload),\n profile: payload,\n }));\n };\n\n // Bridge into @thunderid/react's own ThunderIDContext. Internal react components rendered by\n // BaseSignIn/BaseSignUp — most notably FlowMetaProvider, which fetches `/flow/meta` and injects\n // its i18n bundle — call react's `useThunderID()` directly. Without this bridge they'd only see\n // react's context default (applicationId/baseUrl undefined, isInitialized false), so the meta\n // fetch would never fire and flow labels would render as untranslated i18n keys. Fields with no\n // nextjs equivalent (token/http helpers meant for direct browser API calls) are stubbed out,\n // since nextjs routes those operations through server actions instead.\n const unsupported = (name: string): (() => Promise<never>) => {\n return () =>\n Promise.reject(\n new ThunderIDRuntimeError(\n `\\`${name}\\` is not supported in @thunderid/nextjs.`,\n `ThunderIDClientProvider-${name}-NotSupportedError-001`,\n 'nextjs',\n ),\n );\n };\n\n const reactContextValue: ReactThunderIDContextProps = useMemo(\n () => ({\n afterSignInUrl: undefined,\n applicationId,\n baseUrl,\n clearSession,\n clientId: undefined,\n discovery: {wellKnown: null},\n exchangeToken: unsupported('exchangeToken'),\n getAccessToken: unsupported('getAccessToken'),\n getDecodedIdToken: unsupported('getDecodedIdToken'),\n getIdToken: unsupported('getIdToken'),\n getStorageManager: () => Promise.resolve(null),\n http: {\n request: unsupported('http.request'),\n requestAll: unsupported('http.requestAll'),\n },\n instanceId: 0,\n isInitialized: !isLoading,\n isLoading,\n isMetaLoading: false,\n isSignedIn,\n meta: initialMeta ?? null,\n organizationHandle,\n reInitialize: unsupported('reInitialize'),\n recover: unsupported('recover'),\n resolveFlowTemplateLiterals: (text: string | undefined): string => text ?? '',\n scopes,\n signIn: handleSignIn,\n signInSilently: unsupported('signInSilently'),\n signInUrl,\n signOut: handleSignOut,\n signUp: handleSignUp,\n signUpUrl,\n user,\n vendor: getVendorPrefix(vendor),\n }),\n [\n applicationId,\n baseUrl,\n clearSession,\n isLoading,\n isSignedIn,\n organizationHandle,\n scopes,\n signInUrl,\n signUpUrl,\n user,\n initialMeta,\n vendor,\n ],\n );\n\n return (\n <ThunderIDContext.Provider value={contextValue}>\n <ReactThunderIDContext.Provider value={reactContextValue}>\n <I18nProvider preferences={preferences?.i18n}>\n <FlowMetaProvider enabled={preferences?.resolveFromMeta !== false} initialMeta={initialMeta}>\n <ThemeProvider theme={preferences?.theme?.overrides} mode={getActiveTheme(preferences?.theme?.mode as any)}>\n <FlowProvider>\n <UserProvider profile={userProfile} onUpdateProfile={handleProfileUpdate} updateProfile={updateProfile}>\n {children}\n </UserProvider>\n </FlowProvider>\n </ThemeProvider>\n </FlowMetaProvider>\n </I18nProvider>\n </ReactThunderIDContext.Provider>\n </ThunderIDContext.Provider>\n );\n};\n\nexport default ThunderIDClientProvider;\n"],"mappings":";;;;;;;;;;;;AAgFA,MAAMA,2BAAgF,EACpF,SACA,UACA,QACA,cACA,cACA,SACA,QACA,qBACA,aACA,YACA,WACA,WACA,MAAM,OACN,aAAa,cACb,eACA,eACA,oBACA,QACA,QACA,cAAc,WACuC;CACrD,MAAMC,mBAAuC,OAAO,MAAM;CAC1D,MAAMC,SAA4B,WAAW;CAC7C,MAAMC,eAAwC,iBAAiB;CAC/D,MAAM,CAAC,WAAW,gBAAgB,SAAkB,KAAK;CACzD,MAAM,CAAC,MAAM,WAAW,SAAsB,MAAM;CACpD,MAAM,CAAC,aAAa,kBAAkB,SAAsB,aAAa;AAEzE,iBAAgB;AACd,iBAAe,aAAa;IAC3B,CAAC,aAAa,CAAC;AAElB,iBAAgB;AACd,UAAQ,MAAM;IACb,CAAC,MAAM,CAAC;AAGX,iBAAgB;AAOd,MAAI,iBAAiB,QACnB;AAGF,mBAAiB,UAAU;AAG3B,MAAI,WAAY;AAEhB,GAAC,YAA2B;AAC1B,OAAI;IACF,MAAMC,OAAsB,aAAa,IAAI,OAAO;IACpD,MAAMC,QAAuB,aAAa,IAAI,QAAQ;IACtD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AAc,YAAY,eAAe;EACzC,SAAS,YAAY,UAAU;EAC/B,8BAA8B,SAAqC,QAAQ;EAC3E;EACA,QAAQ;EACR,gBAAgB,YAAY,iBAAiB;EAC7C;EACA,SAAS;EACT,QAAQ;EACR;EACA;EACA,QAAQ,gBAAgB,OAAO;EAChC,GACD;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACF;AAED,QACE,oBAACC,yBAAiB;EAAS,OAAO;YAChC,oBAACC,iBAAsB;GAAS,OAAO;aACrC,oBAAC;IAAa,aAAa,aAAa;cACtC,oBAAC;KAAiB,SAAS,aAAa,oBAAoB;KAAoB;eAC9E,oBAAC;MAAc,OAAO,aAAa,OAAO;MAAW,MAAM,eAAe,aAAa,OAAO,KAAY;gBACxG,oBAAC,0BACC,oBAAC;OAAa,SAAS;OAAa,iBAAiB;OAAoC;OACtF;QACY,GACF;OACD;MACC;KACN;IACgB;GACP;;AAIhC,gCAAe"}
1
+ {"version":3,"file":"ThunderIDProvider.js","names":["ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps>>","reRenderCheckRef: RefObject<boolean>","router: AppRouterInstance","searchParams: ReadonlyURLSearchParams","code: string | null","state: string | null","sessionState: string | null","result: {error?: string; redirectUrl?: string; success: boolean}","result: any","contextValue: ThunderIDContextProps","reactContextValue: ReactThunderIDContextProps","ThunderIDContext","ReactThunderIDContext"],"sources":["../../../../src/client/contexts/ThunderID/ThunderIDProvider.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {\n EmbeddedFlowExecuteRequestConfig,\n FlowMetadataResponse,\n generateFlattenedUserProfile,\n UpdateMeProfileConfig,\n User,\n UserProfile,\n ThunderIDRuntimeError,\n getVendorPrefix,\n} from '@thunderid/node';\nimport {\n I18nProvider,\n FlowMetaProvider,\n FlowProvider,\n UserProvider,\n ThemeProvider,\n ThunderIDContext as ReactThunderIDContext,\n ThunderIDContextProps as ReactThunderIDContextProps,\n ThunderIDProviderProps,\n getActiveTheme,\n} from '@thunderid/react';\nimport {ReadonlyURLSearchParams} from 'next/dist/client/components/navigation.react-server';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter, useSearchParams} from 'next/navigation';\nimport {FC, PropsWithChildren, RefObject, useEffect, useMemo, useRef, useState} from 'react';\nimport ThunderIDContext, {ThunderIDContextProps} from './ThunderIDContext';\nimport {RefreshResult} from '../../../server/actions/refreshToken';\nimport logger from '../../../utils/logger';\n\n/**\n * Props interface of {@link ThunderIDClientProvider}\n */\nexport type ThunderIDClientProviderProps = Partial<Omit<ThunderIDProviderProps, 'baseUrl' | 'clientId'>> &\n Pick<ThunderIDProviderProps, 'baseUrl' | 'clientId'> & {\n applicationId: ThunderIDContextProps['applicationId'];\n clearSession: () => Promise<void>;\n handleOAuthCallback: (\n code: string,\n state: string,\n sessionState?: string,\n ) => Promise<{error?: string; redirectUrl?: string; success: boolean}>;\n /**\n * Flow metadata fetched server-side ahead of time, seeding `FlowMetaProvider` so it can skip\n * its own initial client-side fetch (avoiding a flash of untranslated i18n keys).\n */\n initialMeta?: FlowMetadataResponse | null;\n isSignedIn: boolean;\n organizationHandle: ThunderIDContextProps['organizationHandle'];\n refreshToken: () => Promise<RefreshResult>;\n signIn: ThunderIDContextProps['signIn'];\n signOut: ThunderIDContextProps['signOut'];\n signUp: ThunderIDContextProps['signUp'];\n updateProfile: (\n requestConfig: UpdateMeProfileConfig,\n sessionId?: string,\n ) => Promise<{data: {user: User}; error: string; success: boolean}>;\n user: User | null;\n userProfile: UserProfile;\n };\n\nconst ThunderIDClientProvider: FC<PropsWithChildren<ThunderIDClientProviderProps>> = ({\n baseUrl,\n children,\n signIn,\n clearSession,\n refreshToken,\n signOut,\n signUp,\n handleOAuthCallback,\n preferences,\n isSignedIn,\n signInUrl,\n signUpUrl,\n user: _user,\n userProfile: _userProfile,\n updateProfile,\n applicationId,\n organizationHandle,\n scopes,\n vendor,\n initialMeta = null,\n}: PropsWithChildren<ThunderIDClientProviderProps>) => {\n const reRenderCheckRef: RefObject<boolean> = useRef(false);\n const router: AppRouterInstance = useRouter();\n const searchParams: ReadonlyURLSearchParams = useSearchParams();\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [user, setUser] = useState<User | null>(_user);\n const [userProfile, setUserProfile] = useState<UserProfile>(_userProfile);\n\n useEffect(() => {\n setUserProfile(_userProfile);\n }, [_userProfile]);\n\n useEffect(() => {\n setUser(_user);\n }, [_user]);\n\n // Handle OAuth callback automatically\n useEffect(() => {\n // React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.\n // https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state\n // This will remount all the useEffects to ensure that there are no unexpected side effects.\n // When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to\n // prevent the re-render of this hook as suggested in the following discussion.\n // https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623\n if (reRenderCheckRef.current) {\n return;\n }\n\n reRenderCheckRef.current = true;\n\n // Don't handle callback if already signed in\n if (isSignedIn) return;\n\n (async (): Promise<void> => {\n try {\n const code: string | null = searchParams.get('code');\n const state: string | null = searchParams.get('state');\n const sessionState: string | null = searchParams.get('session_state');\n const error: string | null = searchParams.get('error');\n\n // Check for OAuth errors first\n if (error) {\n logger.error('[ThunderIDClientProvider] An error was received for the initiated sign-in request.');\n\n return;\n }\n\n // Handle OAuth callback if code and state are present\n if (code && state) {\n setIsLoading(true);\n\n const result: {error?: string; redirectUrl?: string; success: boolean} = await handleOAuthCallback(\n code,\n state,\n sessionState || undefined,\n );\n\n if (result.success) {\n // Redirect to the success URL\n if (result.redirectUrl) {\n router.push(result.redirectUrl);\n } else {\n // Refresh the page to update authentication state\n window.location.reload();\n }\n } else {\n logger.error(\n `[ThunderIDClientProvider] An error occurred while signing in: ${result.error || 'Authentication failed'}`,\n );\n }\n }\n } catch (error) {\n logger.error('[ThunderIDClientProvider] Failed to handle OAuth callback:', error);\n }\n })();\n }, []);\n\n useEffect(() => {\n // Set loading to false when server has resolved authentication state\n setIsLoading(false);\n }, [isSignedIn, user]);\n\n const handleSignIn = async (payload: any, request: EmbeddedFlowExecuteRequestConfig): Promise<any> => {\n if (!signIn) {\n throw new ThunderIDRuntimeError(\n '`signIn` function is not available.',\n 'ThunderIDClientProvider-handleSignIn-RuntimeError-001',\n 'nextjs',\n );\n }\n\n const result: any = await signIn(payload, request);\n\n // Redirect based flow URL is sent as `signInUrl` in the response.\n // Use window.location.href instead of router.push() — the OAuth authorization\n // endpoint is on an external server, and router.push() would send RSC fetch\n // headers that the identity provider doesn't understand, causing a CORS error.\n if (result?.data?.signInUrl) {\n window.location.href = result.data.signInUrl;\n\n return undefined;\n }\n\n // After the Embedded flow is successful, the URL to navigate next is sent as `afterSignInUrl` in the response.\n if (result?.data?.afterSignInUrl) {\n router.push(result.data.afterSignInUrl);\n\n return undefined;\n }\n\n if (result?.error) {\n throw new Error(result.error);\n }\n\n return result?.data ?? result;\n };\n\n const handleSignUp = async (payload: any, request: EmbeddedFlowExecuteRequestConfig): Promise<any> => {\n if (!signUp) {\n throw new ThunderIDRuntimeError(\n '`signUp` function is not available.',\n 'ThunderIDClientProvider-handleSignUp-RuntimeError-001',\n 'nextjs',\n );\n }\n\n const result: any = await signUp(payload, request);\n\n // Redirect based flow URL is sent as `signUpUrl` in the response.\n if (result?.data?.signUpUrl) {\n router.push(result.data.signUpUrl);\n\n return undefined;\n }\n\n // After the Embedded flow is successful, the URL to navigate next is sent as `afterSignUpUrl` in the response.\n if (result?.data?.afterSignUpUrl) {\n router.push(result.data.afterSignUpUrl);\n\n return undefined;\n }\n\n if (result?.error) {\n throw new Error(result.error);\n }\n\n return result?.data ?? result;\n };\n\n const handleSignOut = async (): Promise<any> => {\n logger.debug('[ThunderIDClientProvider][handleSignOut] `handleSignOut` called.');\n\n try {\n const result: any = await signOut();\n\n logger.debug('[ThunderIDClientProvider][handleSignOut] Sign out result:', result);\n\n if (result?.data?.afterSignOutUrl) {\n router.push(result.data.afterSignOutUrl);\n\n return {location: result.data.afterSignOutUrl, redirected: true};\n }\n\n if (result?.error) {\n logger.error(\n '[ThunderIDClientProvider][handleSignOut] Error result was returned during signing the user out with a button click:',\n result.error,\n );\n }\n\n return result?.data ?? result;\n } catch (error) {\n logger.error(\n '[ThunderIDClientProvider][handleSignOut] Error occurred during signing the user out with a button click:',\n error,\n );\n\n return undefined;\n }\n };\n\n const contextValue: ThunderIDContextProps = useMemo(\n () => ({\n applicationId,\n baseUrl,\n clearSession,\n isLoading,\n isSignedIn,\n organizationHandle,\n preferences,\n refreshToken,\n scopes,\n signIn: handleSignIn,\n signInUrl,\n signOut: handleSignOut,\n signUp: handleSignUp,\n signUpUrl,\n user,\n }),\n [\n baseUrl,\n user,\n isSignedIn,\n isLoading,\n signInUrl,\n signUpUrl,\n applicationId,\n organizationHandle,\n scopes,\n preferences,\n ],\n );\n\n const handleProfileUpdate = (payload: User): void => {\n setUser(payload);\n setUserProfile((prev: UserProfile) => ({\n ...prev,\n flattenedProfile: generateFlattenedUserProfile(payload),\n profile: payload,\n }));\n };\n\n // Bridge into @thunderid/react's own ThunderIDContext. Internal react components rendered by\n // BaseSignIn/BaseSignUp — most notably FlowMetaProvider, which fetches `/flow/meta` and injects\n // its i18n bundle — call react's `useThunderID()` directly. Without this bridge they'd only see\n // react's context default (applicationId/baseUrl undefined, isInitialized false), so the meta\n // fetch would never fire and flow labels would render as untranslated i18n keys. Fields with no\n // nextjs equivalent (token/http helpers meant for direct browser API calls) are stubbed out,\n // since nextjs routes those operations through server actions instead.\n const unsupported = (name: string): (() => Promise<never>) => {\n return () =>\n Promise.reject(\n new ThunderIDRuntimeError(\n `\\`${name}\\` is not supported in @thunderid/nextjs.`,\n `ThunderIDClientProvider-${name}-NotSupportedError-001`,\n 'nextjs',\n ),\n );\n };\n\n const reactContextValue: ReactThunderIDContextProps = useMemo(\n () => ({\n afterSignInUrl: undefined,\n applicationId,\n baseUrl,\n clearSession,\n clientId: undefined,\n discovery: {wellKnown: null},\n exchangeToken: unsupported('exchangeToken'),\n getAccessToken: unsupported('getAccessToken'),\n getDecodedIdToken: unsupported('getDecodedIdToken'),\n getIdToken: unsupported('getIdToken'),\n getStorageManager: () => Promise.resolve(null),\n http: {\n request: unsupported('http.request'),\n requestAll: unsupported('http.requestAll'),\n },\n instanceId: 0,\n isInitialized: !isLoading,\n isLoading,\n isMetaLoading: false,\n isSignedIn,\n meta: initialMeta ?? null,\n organizationHandle,\n reInitialize: unsupported('reInitialize'),\n recover: unsupported('recover'),\n resolveFlowTemplateLiterals: (text: string | undefined): string => text ?? '',\n scopes,\n signIn: handleSignIn,\n signInSilently: unsupported('signInSilently'),\n signInUrl,\n signOut: handleSignOut,\n signUp: handleSignUp,\n signUpUrl,\n user,\n vendor: getVendorPrefix(vendor),\n }),\n [\n applicationId,\n baseUrl,\n clearSession,\n isLoading,\n isSignedIn,\n organizationHandle,\n scopes,\n signInUrl,\n signUpUrl,\n user,\n initialMeta,\n vendor,\n ],\n );\n\n return (\n <ThunderIDContext.Provider value={contextValue}>\n <ReactThunderIDContext.Provider value={reactContextValue}>\n <I18nProvider preferences={preferences?.i18n}>\n <FlowMetaProvider enabled={preferences?.resolveFromMeta !== false} initialMeta={initialMeta}>\n <ThemeProvider theme={preferences?.theme?.overrides} mode={getActiveTheme(preferences?.theme?.mode as any)}>\n <FlowProvider>\n <UserProvider profile={userProfile} onUpdateProfile={handleProfileUpdate} updateProfile={updateProfile}>\n {children}\n </UserProvider>\n </FlowProvider>\n </ThemeProvider>\n </FlowMetaProvider>\n </I18nProvider>\n </ReactThunderIDContext.Provider>\n </ThunderIDContext.Provider>\n );\n};\n\nexport default ThunderIDClientProvider;\n"],"mappings":";;;;;;;;;;;;AAiEA,MAAMA,2BAAgF,EACpF,SACA,UACA,QACA,cACA,cACA,SACA,QACA,qBACA,aACA,YACA,WACA,WACA,MAAM,OACN,aAAa,cACb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2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { ThunderIDContextProps } from './ThunderIDContext';
19
2
  declare const useThunderID: () => ThunderIDContextProps;
20
3
  export default useThunderID;
@@ -1 +1 @@
1
- {"version":3,"file":"useThunderID.d.ts","sourceRoot":"","sources":["../../../../src/client/contexts/ThunderID/useThunderID.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAyB,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAE3E,QAAA,MAAM,YAAY,QAAO,qBAQxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"useThunderID.d.ts","sourceRoot":"","sources":["../../../../src/client/contexts/ThunderID/useThunderID.ts"],"names":[],"mappings":"AAMA,OAAyB,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAE3E,QAAA,MAAM,YAAY,QAAO,qBAQxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useThunderID.js","names":["context: ThunderIDContextProps | null","ThunderIDContext"],"sources":["../../../../src/client/contexts/ThunderID/useThunderID.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 client';\n\nimport {useContext} from 'react';\nimport ThunderIDContext, {ThunderIDContextProps} from './ThunderIDContext';\n\nconst useThunderID = (): ThunderIDContextProps => {\n const context: ThunderIDContextProps | null = useContext(ThunderIDContext);\n\n if (!context) {\n throw new Error('useThunderID must be used within an ThunderIDProvider');\n }\n\n return context;\n};\n\nexport default useThunderID;\n"],"mappings":";;;;;;;AAuBA,MAAM,qBAA4C;CAChD,MAAMA,UAAwC,WAAWC,yBAAiB;AAE1E,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,wDAAwD;AAG1E,QAAO;;AAGT,2BAAe"}
1
+ {"version":3,"file":"useThunderID.js","names":["context: ThunderIDContextProps | null","ThunderIDContext"],"sources":["../../../../src/client/contexts/ThunderID/useThunderID.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {useContext} from 'react';\nimport ThunderIDContext, {ThunderIDContextProps} from './ThunderIDContext';\n\nconst useThunderID = (): ThunderIDContextProps => {\n const context: ThunderIDContextProps | null = useContext(ThunderIDContext);\n\n if (!context) {\n throw new Error('useThunderID must be used within an ThunderIDProvider');\n }\n\n return context;\n};\n\nexport default useThunderID;\n"],"mappings":";;;;;;;AAQA,MAAM,qBAA4C;CAChD,MAAMA,UAAwC,WAAWC,yBAAiB;AAE1E,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,wDAAwD;AAG1E,QAAO;;AAGT,2BAAe"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  export { default as useThunderID } from './contexts/ThunderID/useThunderID';
19
2
  export { default as SignedIn } from './components/control/SignedIn/SignedIn';
20
3
  export type { SignedInProps } from './components/control/SignedIn/SignedIn';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,wCAAwC,CAAC;AAC3E,YAAY,EAAC,aAAa,EAAC,MAAM,wCAAwC,CAAC;AAE1E,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,0CAA0C,CAAC;AAC9E,YAAY,EAAC,cAAc,EAAC,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gDAAgD,CAAC;AACvF,YAAY,EAAC,iBAAiB,EAAC,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gDAAgD,CAAC;AACvF,YAAY,EAAC,iBAAiB,EAAC,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,yCAAyC,CAAC;AAC1E,YAAY,EAAC,WAAW,EAAC,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,kDAAkD,CAAC;AAC1F,YAAY,EAAC,kBAAkB,EAAC,MAAM,kDAAkD,CAAC;AAEzF,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,qCAAq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AAC;AAEzE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,kDAAkD,CAAC;AAC1F,YAAY,EAAC,kBAAkB,EAAC,MAAM,kDAAkD,CAAC;AAEzF,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,qCAAqC,CAAC;AACpE,YAAY,EAAC,SAAS,EAAC,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,yCAAyC,CAAC;AAC1E,YAAY,EAAC,WAAW,EAAC,MAAM,yCAAyC,CAAC;AAEzE,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,qDAAqD,CAAC;AAC5F,YAAY,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAC;AAE3F,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,iDAAiD,CAAC;AACtF,YAAY,EAAC,eAAe,EAAC,MAAM,iDAAiD,CAAC;AAErF,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,mDAAmD,CAAC;AACzF,YAAY,EAAC,gBAAgB,EAAC,MAAM,mDAAmD,CAAC"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { InternalAuthAPIRoutes } from '../models/api';
19
2
  declare const InternalAuthAPIRoutesConfig: InternalAuthAPIRoutes;
20
3
  export default InternalAuthAPIRoutesConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"InternalAuthAPIRoutesConfig.d.ts","sourceRoot":"","sources":["../../src/configs/InternalAuthAPIRoutesConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAEpD,QAAA,MAAM,2BAA2B,EAAE,qBAMlC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"InternalAuthAPIRoutesConfig.d.ts","sourceRoot":"","sources":["../../src/configs/InternalAuthAPIRoutesConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAEpD,QAAA,MAAM,2BAA2B,EAAE,qBAMlC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  /**
19
2
  * Number of seconds before access token expiry at which the SDK proactively
20
3
  * refreshes the token. A 25-second buffer prevents races where the token is
@@ -1 +1 @@
1
- {"version":3,"file":"sessionConstants.d.ts","sourceRoot":"","sources":["../../src/constants/sessionConstants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kCAAkC,QAAQ,CAAC"}
1
+ {"version":3,"file":"sessionConstants.d.ts","sourceRoot":"","sources":["../../src/constants/sessionConstants.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kCAAkC,QAAQ,CAAC"}
@@ -1,22 +1,5 @@
1
1
  //#region src/constants/sessionConstants.ts
2
2
  /**
3
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4
- *
5
- * WSO2 LLC. licenses this file to you under the Apache License,
6
- * Version 2.0 (the "License"); you may not use this file except
7
- * in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing,
13
- * software distributed under the License is distributed on an
14
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- * KIND, either express or implied. See the License for the
16
- * specific language governing permissions and limitations
17
- * under the License.
18
- */
19
- /**
20
3
  * Number of seconds before access token expiry at which the SDK proactively
21
4
  * refreshes the token. A 25-second buffer prevents races where the token is
22
5
  * valid when a request starts but expires mid-flight.
@@ -1 +1 @@
1
- {"version":3,"file":"sessionConstants.js","names":[],"sources":["../../src/constants/sessionConstants.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/**\n * Number of seconds before access token expiry at which the SDK proactively\n * refreshes the token. A 25-second buffer prevents races where the token is\n * valid when a request starts but expires mid-flight.\n */\nexport const REFRESH_BUFFER_SECONDS = 25;\n\n/**\n * Default session cookie lifetime in seconds (24 hours).\n *\n * Used when no explicit session cookie expiry is configured. The session cookie\n * lifetime can be overridden in two ways (evaluated in this order):\n *\n * 1. `sessionCookie.expiryTime` in `ThunderIDNodeConfig` — set programmatically\n * when initialising the SDK.\n * 2. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME` environment variable — set in `.env`\n * (e.g. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME=86400`).\n * 3. This constant — applied when neither of the above is present.\n *\n * Two independent expiry bounds apply to the session and they are generally\n * NOT the same value:\n *\n * - JWT `exp` claim — set by `SessionManager.createSessionToken(...)` from\n * the `accessTokenTtlSeconds` argument (i.e. the access token's `expires_in`\n * returned by the auth server, typically ~1 hour). This controls when\n * `verifySessionToken` rejects the token and is the trigger for a refresh.\n * - Browser cookie `maxAge` — set by the caller (sign-in / refresh / org-switch\n * actions) from `SessionManager.resolveSessionCookieExpiry(...)`, which returns\n * this constant by default (24 hours). This controls how long the browser\n * holds the cookie before discarding it.\n */\nexport const DEFAULT_SESSION_COOKIE_EXPIRY_TIME = 86400;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;AA0BtC,MAAa,qCAAqC"}
1
+ {"version":3,"file":"sessionConstants.js","names":[],"sources":["../../src/constants/sessionConstants.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Number of seconds before access token expiry at which the SDK proactively\n * refreshes the token. A 25-second buffer prevents races where the token is\n * valid when a request starts but expires mid-flight.\n */\nexport const REFRESH_BUFFER_SECONDS = 25;\n\n/**\n * Default session cookie lifetime in seconds (24 hours).\n *\n * Used when no explicit session cookie expiry is configured. The session cookie\n * lifetime can be overridden in two ways (evaluated in this order):\n *\n * 1. `sessionCookie.expiryTime` in `ThunderIDNodeConfig` — set programmatically\n * when initialising the SDK.\n * 2. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME` environment variable — set in `.env`\n * (e.g. `THUNDERID_SESSION_COOKIE_EXPIRY_TIME=86400`).\n * 3. This constant — applied when neither of the above is present.\n *\n * Two independent expiry bounds apply to the session and they are generally\n * NOT the same value:\n *\n * - JWT `exp` claim — set by `SessionManager.createSessionToken(...)` from\n * the `accessTokenTtlSeconds` argument (i.e. the access token's `expires_in`\n * returned by the auth server, typically ~1 hour). This controls when\n * `verifySessionToken` rejects the token and is the trigger for a refresh.\n * - Browser cookie `maxAge` — set by the caller (sign-in / refresh / org-switch\n * actions) from `SessionManager.resolveSessionCookieExpiry(...)`, which returns\n * this constant by default (24 hours). This controls how long the browser\n * holds the cookie before discarding it.\n */\nexport const DEFAULT_SESSION_COOKIE_EXPIRY_TIME = 86400;\n"],"mappings":";;;;;;AAQA,MAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;AA0BtC,MAAa,qCAAqC"}
package/dist/index.d.ts CHANGED
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  export { default as ThunderIDNext } from './ThunderIDNextClient';
19
2
  export * from './server';
20
3
  export * from './client';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAG/D,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAG/D,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  /**
19
2
  * Interface defining the internal API routes for authentication.
20
3
  * These routes are used internally by the ThunderID Next.js SDK for handling authentication flows.
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/models/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/models/api.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { ThunderIDNodeConfig } from '@thunderid/node';
19
2
  /**
20
3
  * Configuration type for the ThunderID Next.js SDK.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC"}
@@ -1,20 +1,3 @@
1
- /**
2
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
3
- *
4
- * WSO2 LLC. licenses this file to you under the Apache License,
5
- * Version 2.0 (the "License"); you may not use this file except
6
- * in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing,
12
- * software distributed under the License is distributed on an
13
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- * KIND, either express or implied. See the License for the
15
- * specific language governing permissions and limitations
16
- * under the License.
17
- */
18
1
  import { ThunderIDProviderProps } from '@thunderid/react';
19
2
  import { FC, PropsWithChildren } from 'react';
20
3
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDProvider.d.ts","sourceRoot":"","sources":["../../src/server/ThunderIDProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAeH,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAmB1D;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CA8IhF,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
1
+ {"version":3,"file":"ThunderIDProvider.d.ts","sourceRoot":"","sources":["../../src/server/ThunderIDProvider.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAmB1D;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,uBAAuB,EAAE,EAAE,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,CA8IhF,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDProvider.js","names":["ThunderIDServerProvider: FC<PropsWithChildren<ThunderIDServerProviderProps>>","getClient","config: Partial<ThunderIDNextConfig>","flowMeta: FlowMetadataResponse | null","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 {\n ThunderIDRuntimeError,\n FlowMetadataResponse,\n FlowMetaType,\n IdToken,\n User,\n UserProfile,\n getFlowMeta,\n extractUserClaimsFromIdToken,\n resolveResourceEndpoint,\n} 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 // Fetch flow metadata (design config + i18n bundle) server-side so `FlowMetaProvider` can seed\n // its state and skip a redundant client-side fetch — avoiding a flash of untranslated i18n keys\n // (e.g. raw `signin.forms.credentials.title`) while embedded flow components first render.\n let flowMeta: FlowMetadataResponse | null = null;\n try {\n flowMeta = await getFlowMeta({\n baseUrl: config?.baseUrl,\n url: resolveResourceEndpoint('flowMeta', config),\n ...(config?.applicationId ? {id: config.applicationId, type: FlowMetaType.App} : {}),\n });\n } catch (error) {\n logger.warn('[ThunderIDServerProvider] Failed to fetch flow metadata:', error?.toString());\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 };\n\n const resolvedPreferences = {\n ...config?.preferences,\n ..._config.preferences,\n user: {\n ...config?.preferences?.user,\n ..._config.preferences?.user,\n },\n };\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 = resolvedPreferences?.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 /users/me:', error?.toString());\n }\n } else {\n try {\n const decodedIdToken: IdToken = await thunderIDClient.getDecodedIdToken(sessionId);\n const claims = extractUserClaimsFromIdToken(decodedIdToken);\n user = claims;\n userProfile = {\n flattenedProfile: claims,\n profile: claims,\n };\n } catch (error) {\n logger.warn('[ThunderIDServerProvider] Failed to extract user claims from ID token:', error?.toString());\n }\n }\n }\n\n return (\n <ThunderIDClientProvider\n organizationHandle={config?.organizationHandle}\n applicationId={config?.applicationId}\n baseUrl={config?.baseUrl}\n initialMeta={flowMeta}\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={resolvedPreferences}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,MAAMA,0BAA+E,OAAO,EAC1F,UACA,gBACA,gBACA,GAAG,cACyE;CAC5E,MAAM,kBAAkBC,mBAAW;CACnC,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;AAQV,MAFwC,qBAAqB,MAAM,qBAAqB,MAGtF,KAAI;GACF,MAAMC,eAIF,MAAMC,sBAAc,UAAU;GAClC,MAAMC,sBAIF,MAAMC,6BAAqB,UAAU;AAEzC,UAAO,aAAa,MAAM,QAAQ,EAAE;AACpC,iBAAc,oBAAoB,MAAM,eAAe;WAChD,OAAO;AACd,kBAAO,KAAK,0EAA0E,OAAO,UAAU,CAAC;;MAG1G,KAAI;GAEF,MAAM,SAAS,6BADiB,MAAM,gBAAgB,kBAAkB,UAAU,CACvB;AAC3D,UAAO;AACP,iBAAc;IACZ,kBAAkB;IAClB,SAAS;IACV;WACM,OAAO;AACd,kBAAO,KAAK,0EAA0E,OAAO,UAAU,CAAC;;;AAK9G,QACE,oBAACC;EACC,oBAAoB,QAAQ;EAC5B,eAAe,QAAQ;EACvB,SAAS,QAAQ;EACjB,aAAa;EACb,QAAQC;EACR,cAAcC;EACd,cAAcC;EACd,SAASC;EACT,QAAQC;EACR,qBAAqBC;EACrB,WAAW,QAAQ;EACnB,WAAW,QAAQ;EACnB,aAAa;EACb,UAAU,QAAQ;EACZ;EACO;EACb,eAAeC;EACf,YAAY;EAEX;GACuB;;AAI9B,kCAAe"}
1
+ {"version":3,"file":"ThunderIDProvider.js","names":["ThunderIDServerProvider: FC<PropsWithChildren<ThunderIDServerProviderProps>>","getClient","config: Partial<ThunderIDNextConfig>","flowMeta: FlowMetadataResponse | null","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":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use server';\n\nimport {\n ThunderIDRuntimeError,\n FlowMetadataResponse,\n FlowMetaType,\n IdToken,\n User,\n UserProfile,\n getFlowMeta,\n extractUserClaimsFromIdToken,\n resolveResourceEndpoint,\n} 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 // Fetch flow metadata (design config + i18n bundle) server-side so `FlowMetaProvider` can seed\n // its state and skip a redundant client-side fetch — avoiding a flash of untranslated i18n keys\n // (e.g. raw `signin.forms.credentials.title`) while embedded flow components first render.\n let flowMeta: FlowMetadataResponse | null = null;\n try {\n flowMeta = await getFlowMeta({\n baseUrl: config?.baseUrl,\n url: resolveResourceEndpoint('flowMeta', config),\n ...(config?.applicationId ? {id: config.applicationId, type: FlowMetaType.App} : {}),\n });\n } catch (error) {\n logger.warn('[ThunderIDServerProvider] Failed to fetch flow metadata:', error?.toString());\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 };\n\n const resolvedPreferences = {\n ...config?.preferences,\n ..._config.preferences,\n user: {\n ...config?.preferences?.user,\n ..._config.preferences?.user,\n },\n };\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 = resolvedPreferences?.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 /users/me:', error?.toString());\n }\n } else {\n try {\n const decodedIdToken: IdToken = await thunderIDClient.getDecodedIdToken(sessionId);\n const claims = extractUserClaimsFromIdToken(decodedIdToken);\n user = claims;\n userProfile = {\n flattenedProfile: claims,\n profile: claims,\n };\n } catch (error) {\n logger.warn('[ThunderIDServerProvider] Failed to extract user claims from ID token:', error?.toString());\n }\n }\n }\n\n return (\n <ThunderIDClientProvider\n organizationHandle={config?.organizationHandle}\n applicationId={config?.applicationId}\n baseUrl={config?.baseUrl}\n initialMeta={flowMeta}\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={resolvedPreferences}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAMA,0BAA+E,OAAO,EAC1F,UACA,gBACA,gBACA,GAAG,cACyE;CAC5E,MAAM,kBAAkBC,mBAAW;CACnC,IAAIC,SAAuC,EAAE;AAE7C,KAAI;AACF,QAAM,gBAAgB,WAAW,QAA+B;AAEhE,iBAAO,MAAM,uEAAuE;AAEpF,WAAS,MAAM,gBAAgB,kBAAkB;UAC1C,OAAO;AACd,iBAAO,MAAM,oEAAoE,OAAO,UAAU,CAAC;AAEnG,QAAM,IAAI,sBACR,0CAA0C,OAAO,UAAU,IAC3D,+BACA,QACA,8FACD;;AAGH,KAAI,CAAC,gBAAgB,cACnB,QAAO,iCAAK;CAMd,IAAIC,WAAwC;AAC5C,KAAI;AACF,aAAW,MAAM,YAAY;GAC3B,SAAS,QAAQ;GACjB,KAAK,wBAAwB,YAAY,OAAO;GAChD,GAAI,QAAQ,gBAAgB;IAAC,IAAI,OAAO;IAAe,MAAM,aAAa;IAAI,GAAG,EAAE;GACpF,CAAC;UACK,OAAO;AACd,iBAAO,KAAK,4DAA4D,OAAO,UAAU,CAAC;;CAI5F,MAAMC,iBAAkD,MAAMC,2BAAmB;CACjF,MAAMC,YAAoB,gBAAgB,aAAc,MAAMC,sBAAc,IAAK;CACjF,MAAMC,WAAoB,MAAMC,mBAAW,UAAU;CAErD,IAAIC,OAAa,EAAE;CACnB,IAAIC,cAA2B;EAC7B,kBAAkB,EAAE;EACpB,SAAS,EAAE;EACZ;CAED,MAAM,sBAAsB;EAC1B,GAAG,QAAQ;EACX,GAAG,QAAQ;EACX,MAAM;GACJ,GAAG,QAAQ,aAAa;GACxB,GAAG,QAAQ,aAAa;GACzB;EACF;AAED,KAAI,UAAU;EACZ,IAAIC,iBAAqC,Q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