@asgardeo/nextjs 0.0.3 → 0.1.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 (76) hide show
  1. package/README.md +68 -8
  2. package/dist/AsgardeoNextClient.d.ts +37 -8
  3. package/dist/AsgardeoNextClient.js +153 -138
  4. package/dist/AsgardeoNextClient.js.map +1 -1
  5. package/dist/cjs/index.js +25 -2
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/client/components/actions/SignInButton/SignInButton.d.ts +2 -2
  8. package/dist/client/components/actions/SignInButton/SignInButton.js +34 -7
  9. package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -1
  10. package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts +1 -2
  11. package/dist/client/components/actions/SignOutButton/SignOutButton.js +25 -4
  12. package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -1
  13. package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts +38 -14
  14. package/dist/client/components/actions/SignUpButton/SignUpButton.js +69 -15
  15. package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -1
  16. package/dist/client/components/control/SignedIn/SignedIn.js +3 -17
  17. package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -1
  18. package/dist/client/components/control/SignedOut/SignedOut.js +3 -17
  19. package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -1
  20. package/dist/client/components/presentation/SignIn/SignIn.d.ts +1 -1
  21. package/dist/client/components/presentation/SignIn/SignIn.js +9 -6
  22. package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -1
  23. package/dist/client/components/presentation/SignUp/SignUp.d.ts +55 -0
  24. package/dist/client/components/presentation/SignUp/SignUp.js +70 -0
  25. package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -0
  26. package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts +105 -0
  27. package/dist/client/components/presentation/UserDropdown/UserDropdown.js +106 -0
  28. package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -0
  29. package/dist/client/components/presentation/UserProfile/UserProfile.d.ts +49 -0
  30. package/dist/client/components/presentation/UserProfile/UserProfile.js +57 -0
  31. package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -0
  32. package/dist/client/contexts/Asgardeo/AsgardeoContext.d.ts +1 -8
  33. package/dist/client/contexts/Asgardeo/AsgardeoContext.js +13 -1
  34. package/dist/client/contexts/Asgardeo/AsgardeoContext.js.map +1 -1
  35. package/dist/client/contexts/Asgardeo/AsgardeoProvider.d.ts +15 -5
  36. package/dist/client/contexts/Asgardeo/AsgardeoProvider.js +115 -49
  37. package/dist/client/contexts/Asgardeo/AsgardeoProvider.js.map +1 -1
  38. package/dist/index.d.ts +12 -0
  39. package/dist/index.js +8 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/middleware/asgardeoMiddleware.d.ts +63 -0
  42. package/dist/middleware/asgardeoMiddleware.js +115 -0
  43. package/dist/middleware/asgardeoMiddleware.js.map +1 -0
  44. package/dist/server/AsgardeoProvider.d.ts +6 -3
  45. package/dist/server/AsgardeoProvider.js +42 -3
  46. package/dist/server/AsgardeoProvider.js.map +1 -1
  47. package/dist/server/actions/getClientOrigin.d.ts +2 -0
  48. package/dist/server/actions/getClientOrigin.js +10 -0
  49. package/dist/server/actions/getClientOrigin.js.map +1 -0
  50. package/dist/server/actions/getUserAction.d.ts +35 -0
  51. package/dist/server/actions/getUserAction.js +35 -0
  52. package/dist/server/actions/getUserAction.js.map +1 -0
  53. package/dist/server/actions/getUserProfileAction.d.ts +40 -0
  54. package/dist/server/actions/getUserProfileAction.js +45 -0
  55. package/dist/server/actions/getUserProfileAction.js.map +1 -0
  56. package/dist/server/actions/handleOAuthCallbackAction.d.ts +33 -0
  57. package/dist/server/actions/handleOAuthCallbackAction.js +80 -0
  58. package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -0
  59. package/dist/server/actions/isSignedIn.d.ts +1 -1
  60. package/dist/server/actions/isSignedIn.js +5 -5
  61. package/dist/server/actions/isSignedIn.js.map +1 -1
  62. package/dist/server/actions/signInAction.d.ts +35 -0
  63. package/dist/server/actions/signInAction.js +71 -0
  64. package/dist/server/actions/signInAction.js.map +1 -0
  65. package/dist/server/actions/signOutAction.d.ts +25 -0
  66. package/dist/server/actions/signOutAction.js +33 -0
  67. package/dist/server/actions/signOutAction.js.map +1 -0
  68. package/dist/server/actions/signUpAction.d.ts +35 -0
  69. package/dist/server/actions/signUpAction.js +52 -0
  70. package/dist/server/actions/signUpAction.js.map +1 -0
  71. package/dist/server/actions/updateUserProfileAction.d.ts +36 -0
  72. package/dist/server/actions/updateUserProfileAction.js +41 -0
  73. package/dist/server/actions/updateUserProfileAction.js.map +1 -0
  74. package/dist/utils/decorateConfigWithNextEnv.js +5 -1
  75. package/dist/utils/decorateConfigWithNextEnv.js.map +1 -1
  76. package/package.json +14 -4
@@ -0,0 +1,70 @@
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
+ 'use client';
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { EmbeddedFlowType, } from '@asgardeo/node';
21
+ import { BaseSignUp } from '@asgardeo/react';
22
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
23
+ /**
24
+ * A styled SignUp component that provides embedded sign-up flow with pre-built styling.
25
+ * This component handles the API calls for sign-up and delegates UI logic to BaseSignUp.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * import { SignUp } from '@asgardeo/react';
30
+ *
31
+ * const App = () => {
32
+ * return (
33
+ * <SignUp
34
+ * onSuccess={(response) => {
35
+ * console.log('Sign-up successful:', response);
36
+ * // Handle successful sign-up (e.g., redirect, show confirmation)
37
+ * }}
38
+ * onError={(error) => {
39
+ * console.error('Sign-up failed:', error);
40
+ * }}
41
+ * onComplete={(redirectUrl) => {
42
+ * // Platform-specific redirect handling (e.g., Next.js router.push)
43
+ * router.push(redirectUrl); // or window.location.href = redirectUrl
44
+ * }}
45
+ * size="medium"
46
+ * variant="outlined"
47
+ * afterSignUpUrl="/welcome"
48
+ * />
49
+ * );
50
+ * };
51
+ * ```
52
+ */
53
+ const SignUp = ({ className, size = 'medium', variant = 'outlined', afterSignUpUrl, onError }) => {
54
+ const { signUp, isInitialized } = useAsgardeo();
55
+ /**
56
+ * Initialize the sign-up flow.
57
+ */
58
+ const handleInitialize = async (payload) => {
59
+ return await signUp(payload || {
60
+ flowType: EmbeddedFlowType.Registration,
61
+ });
62
+ };
63
+ /**
64
+ * Handle sign-up steps.
65
+ */
66
+ const handleOnSubmit = async (payload) => await signUp(payload);
67
+ return (_jsx(BaseSignUp, { afterSignUpUrl: afterSignUpUrl, onInitialize: handleInitialize, onSubmit: handleOnSubmit, onError: onError, className: className, size: size, variant: variant, isInitialized: true }));
68
+ };
69
+ export default SignUp;
70
+ //# sourceMappingURL=SignUp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignUp.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/SignUp/SignUp.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAIL,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAC,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAC5D,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAOjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,GAAoB,CAAC,EAAC,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,GAAG,UAAU,EAAE,cAAc,EAAE,OAAO,EAAC,EAAE,EAAE;IAC9G,MAAM,EAAC,MAAM,EAAE,aAAa,EAAC,GAAG,WAAW,EAAE,CAAC;IAE9C;;OAEG;IACH,MAAM,gBAAgB,GAAG,KAAK,EAC5B,OAA2C,EACL,EAAE;QACxC,OAAO,MAAM,MAAM,CACjB,OAAO,IAAI;YACT,QAAQ,EAAE,gBAAgB,CAAC,YAAY;SACxC,CACF,CAAC;IACJ,CAAC,CAAC;IAEF;;OAEG;IACH,MAAM,cAAc,GAAG,KAAK,EAAE,OAA0C,EAAwC,EAAE,CAChH,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAExB,OAAO,CACL,KAAC,UAAU,IACT,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,IAAI,GACnB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,105 @@
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
+ import { FC, ReactNode } from 'react';
19
+ import { BaseUserDropdownProps } from '@asgardeo/react';
20
+ /**
21
+ * Render props data passed to the children function
22
+ */
23
+ export interface UserDropdownRenderProps {
24
+ /** Function to close the profile dialog */
25
+ closeProfile: () => void;
26
+ /** Whether user data is currently loading */
27
+ isLoading: boolean;
28
+ /** Whether the profile dialog is currently open */
29
+ isProfileOpen: boolean;
30
+ /** Function to open the user profile dialog */
31
+ openProfile: () => void;
32
+ /** Function to sign out the user */
33
+ signOut: () => void;
34
+ /** The authenticated user object */
35
+ user: any;
36
+ }
37
+ /**
38
+ * Props for the UserDropdown component.
39
+ * Extends BaseUserDropdownProps but excludes user, onManageProfile, and onSignOut since they're handled internally
40
+ */
41
+ export type UserDropdownProps = Omit<BaseUserDropdownProps, 'user' | 'onManageProfile'> & {
42
+ /**
43
+ * Render prop function that receives user state and actions.
44
+ * When provided, this completely replaces the default dropdown rendering.
45
+ */
46
+ children?: (props: UserDropdownRenderProps) => ReactNode;
47
+ /**
48
+ * Custom render function for the dropdown content.
49
+ * When provided, this replaces just the dropdown content while keeping the trigger.
50
+ */
51
+ renderDropdown?: (props: UserDropdownRenderProps) => ReactNode;
52
+ /**
53
+ * Custom render function for the trigger button.
54
+ * When provided, this replaces just the trigger button while keeping the dropdown.
55
+ */
56
+ renderTrigger?: (props: UserDropdownRenderProps) => ReactNode;
57
+ };
58
+ /**
59
+ * UserDropdown component displays a user avatar with a dropdown menu.
60
+ * When clicked, it shows a popover with customizable menu items.
61
+ * This component is the React-specific implementation that uses the BaseUserDropdown
62
+ * and automatically retrieves the user data from Asgardeo context.
63
+ *
64
+ * Supports render props for complete customization of the dropdown appearance and behavior.
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * // Basic usage - will use user from Asgardeo context
69
+ * <UserDropdown menuItems={[
70
+ * { label: 'Profile', onClick: () => {} },
71
+ * { label: 'Settings', href: '/settings' },
72
+ * { label: 'Sign Out', onClick: () => {} }
73
+ * ]} />
74
+ *
75
+ * // With custom configuration
76
+ * <UserDropdown
77
+ * showTriggerLabel={true}
78
+ * avatarSize={40}
79
+ * fallback={<div>Please sign in</div>}
80
+ * />
81
+ *
82
+ * // Using render props for complete customization
83
+ * <UserDropdown>
84
+ * {({ user, isLoading, openProfile, signOut }) => (
85
+ * <div>
86
+ * <button onClick={openProfile}>
87
+ * {user?.name || 'Loading...'}
88
+ * </button>
89
+ * <button onClick={signOut}>Logout</button>
90
+ * </div>
91
+ * )}
92
+ * </UserDropdown>
93
+ *
94
+ * // Using partial render props
95
+ * <UserDropdown
96
+ * renderTrigger={({ user, openProfile }) => (
97
+ * <button onClick={openProfile} className="custom-trigger">
98
+ * Welcome, {user?.name}!
99
+ * </button>
100
+ * )}
101
+ * />
102
+ * ```
103
+ */
104
+ declare const UserDropdown: FC<UserDropdownProps>;
105
+ export default UserDropdown;
@@ -0,0 +1,106 @@
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
+ 'use client';
19
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { useState } from 'react';
21
+ import { BaseUserDropdown } from '@asgardeo/react';
22
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
23
+ import UserProfile from '../UserProfile/UserProfile';
24
+ /**
25
+ * UserDropdown component displays a user avatar with a dropdown menu.
26
+ * When clicked, it shows a popover with customizable menu items.
27
+ * This component is the React-specific implementation that uses the BaseUserDropdown
28
+ * and automatically retrieves the user data from Asgardeo context.
29
+ *
30
+ * Supports render props for complete customization of the dropdown appearance and behavior.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * // Basic usage - will use user from Asgardeo context
35
+ * <UserDropdown menuItems={[
36
+ * { label: 'Profile', onClick: () => {} },
37
+ * { label: 'Settings', href: '/settings' },
38
+ * { label: 'Sign Out', onClick: () => {} }
39
+ * ]} />
40
+ *
41
+ * // With custom configuration
42
+ * <UserDropdown
43
+ * showTriggerLabel={true}
44
+ * avatarSize={40}
45
+ * fallback={<div>Please sign in</div>}
46
+ * />
47
+ *
48
+ * // Using render props for complete customization
49
+ * <UserDropdown>
50
+ * {({ user, isLoading, openProfile, signOut }) => (
51
+ * <div>
52
+ * <button onClick={openProfile}>
53
+ * {user?.name || 'Loading...'}
54
+ * </button>
55
+ * <button onClick={signOut}>Logout</button>
56
+ * </div>
57
+ * )}
58
+ * </UserDropdown>
59
+ *
60
+ * // Using partial render props
61
+ * <UserDropdown
62
+ * renderTrigger={({ user, openProfile }) => (
63
+ * <button onClick={openProfile} className="custom-trigger">
64
+ * Welcome, {user?.name}!
65
+ * </button>
66
+ * )}
67
+ * />
68
+ * ```
69
+ */
70
+ const UserDropdown = ({ children, renderTrigger, renderDropdown, onSignOut, ...rest }) => {
71
+ const { user, isLoading, signOut } = useAsgardeo();
72
+ const [isProfileOpen, setIsProfileOpen] = useState(false);
73
+ const handleManageProfile = () => {
74
+ setIsProfileOpen(true);
75
+ };
76
+ const handleSignOut = () => {
77
+ signOut();
78
+ onSignOut && onSignOut();
79
+ };
80
+ const closeProfile = () => {
81
+ setIsProfileOpen(false);
82
+ };
83
+ // Prepare render props data
84
+ const renderProps = {
85
+ user,
86
+ isLoading: isLoading,
87
+ openProfile: handleManageProfile,
88
+ signOut: handleSignOut,
89
+ isProfileOpen,
90
+ closeProfile,
91
+ };
92
+ // If children render prop is provided, use it for complete customization
93
+ if (children) {
94
+ return (_jsxs(_Fragment, { children: [children(renderProps), _jsx(UserProfile, { mode: "popup", open: isProfileOpen, onOpenChange: setIsProfileOpen })] }));
95
+ }
96
+ // If partial render props are provided, customize specific parts
97
+ if (renderTrigger || renderDropdown) {
98
+ // This would require significant changes to BaseUserDropdown to support partial customization
99
+ // For now, we'll provide a simple implementation that shows how it could work
100
+ return (_jsxs(_Fragment, { children: [renderTrigger ? (renderTrigger(renderProps)) : (_jsx(BaseUserDropdown, { user: user, isLoading: isLoading, onManageProfile: handleManageProfile, onSignOut: handleSignOut, ...rest })), _jsx(UserProfile, { mode: "popup", open: isProfileOpen, onOpenChange: setIsProfileOpen })] }));
101
+ }
102
+ // Default behavior - use BaseUserDropdown as before
103
+ return (_jsxs(_Fragment, { children: [_jsx(BaseUserDropdown, { user: user, isLoading: isLoading, onManageProfile: handleManageProfile, onSignOut: handleSignOut, ...rest }), isProfileOpen && _jsx(UserProfile, { mode: "popup", open: isProfileOpen, onOpenChange: setIsProfileOpen })] }));
104
+ };
105
+ export default UserDropdown;
106
+ //# sourceMappingURL=UserDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserDropdown.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/UserDropdown/UserDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAA8B,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAwB,MAAM,iBAAiB,CAAC;AACxE,OAAO,WAAW,MAAM,wCAAwC,CAAC;AACjE,OAAO,WAAW,MAAM,4BAA4B,CAAC;AA0CrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,YAAY,GAA0B,CAAC,EAC3C,QAAQ,EACR,aAAa,EACb,cAAc,EACd,SAAS,EACT,GAAG,IAAI,EACW,EAAgB,EAAE;IACpC,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAC,GAAG,WAAW,EAAE,CAAC;IACjD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1D,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,OAAO,EAAE,CAAC;QACV,SAAS,IAAI,SAAS,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,4BAA4B;IAC5B,MAAM,WAAW,GAA4B;QAC3C,IAAI;QACJ,SAAS,EAAE,SAAoB;QAC/B,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE,aAAa;QACtB,aAAa;QACb,YAAY;KACb,CAAC;IAEF,yEAAyE;IACzE,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CACL,8BACG,QAAQ,CAAC,WAAW,CAAC,EACtB,KAAC,WAAW,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,GAAI,IAChF,CACJ,CAAC;IACJ,CAAC;IAED,iEAAiE;IACjE,IAAI,aAAa,IAAI,cAAc,EAAE,CAAC;QACpC,8FAA8F;QAC9F,8EAA8E;QAC9E,OAAO,CACL,8BACG,aAAa,CAAC,CAAC,CAAC,CACf,aAAa,CAAC,WAAW,CAAC,CAC3B,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,IACf,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,mBAAmB,EACpC,SAAS,EAAE,aAAa,KACpB,IAAI,GACR,CACH,EAED,KAAC,WAAW,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,GAAI,IAChF,CACJ,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,OAAO,CACL,8BACE,KAAC,gBAAgB,IACf,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,mBAAmB,EACpC,SAAS,EAAE,aAAa,KACpB,IAAI,GACR,EACD,aAAa,IAAI,KAAC,WAAW,IAAC,IAAI,EAAC,OAAO,EAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,GAAI,IAClG,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,49 @@
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
+ import { FC } from 'react';
19
+ import { BaseUserProfileProps } from '@asgardeo/react';
20
+ /**
21
+ * Props for the UserProfile component.
22
+ * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useAsgardeo
23
+ */
24
+ export type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile' | 'schemas'>;
25
+ /**
26
+ * UserProfile component displays the authenticated user's profile information in a
27
+ * structured and styled format. It shows user details such as display name, email,
28
+ * username, and other available profile information from Asgardeo.
29
+ *
30
+ * This component is the React-specific implementation that uses the BaseUserProfile
31
+ * and automatically retrieves the user data from Asgardeo context if not provided.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * // Basic usage - will use user from Asgardeo context
36
+ * <UserProfile />
37
+ *
38
+ * // With explicit user data
39
+ * <UserProfile user={specificUser} />
40
+ *
41
+ * // With card layout and custom fallback
42
+ * <UserProfile
43
+ * cardLayout={true}
44
+ * fallback={<div>Please sign in to view your profile</div>}
45
+ * />
46
+ * ```
47
+ */
48
+ declare const UserProfile: FC<UserProfileProps>;
49
+ export default UserProfile;
@@ -0,0 +1,57 @@
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
+ 'use client';
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { BaseUserProfile, useUser } from '@asgardeo/react';
21
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
22
+ import getSessionId from '../../../../server/actions/getSessionId';
23
+ import updateUserProfileAction from '../../../../server/actions/updateUserProfileAction';
24
+ /**
25
+ * UserProfile component displays the authenticated user's profile information in a
26
+ * structured and styled format. It shows user details such as display name, email,
27
+ * username, and other available profile information from Asgardeo.
28
+ *
29
+ * This component is the React-specific implementation that uses the BaseUserProfile
30
+ * and automatically retrieves the user data from Asgardeo context if not provided.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * // Basic usage - will use user from Asgardeo context
35
+ * <UserProfile />
36
+ *
37
+ * // With explicit user data
38
+ * <UserProfile user={specificUser} />
39
+ *
40
+ * // With card layout and custom fallback
41
+ * <UserProfile
42
+ * cardLayout={true}
43
+ * fallback={<div>Please sign in to view your profile</div>}
44
+ * />
45
+ * ```
46
+ */
47
+ const UserProfile = ({ ...rest }) => {
48
+ const { baseUrl } = useAsgardeo();
49
+ const { profile, flattenedProfile, schemas, revalidateProfile } = useUser();
50
+ const handleProfileUpdate = async (payload) => {
51
+ await updateUserProfileAction(payload, (await getSessionId()));
52
+ await revalidateProfile();
53
+ };
54
+ return (_jsx(BaseUserProfile, { profile: profile, flattenedProfile: flattenedProfile, schemas: schemas, onUpdate: handleProfileUpdate, ...rest }));
55
+ };
56
+ export default UserProfile;
57
+ //# sourceMappingURL=UserProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserProfile.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAGb,OAAO,EAAC,eAAe,EAAwB,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC/E,OAAO,WAAW,MAAM,wCAAwC,CAAC;AACjE,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AASzF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,GAAyB,CAAC,EAAC,GAAG,IAAI,EAAmB,EAAgB,EAAE;IACtF,MAAM,EAAC,OAAO,EAAC,GAAG,WAAW,EAAE,CAAC;IAChC,MAAM,EAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAC,GAAG,OAAO,EAAE,CAAC;IAE1E,MAAM,mBAAmB,GAAG,KAAK,EAAE,OAAY,EAAiB,EAAE;QAChE,MAAM,uBAAuB,CAAC,OAAO,EAAE,CAAC,MAAM,YAAY,EAAE,CAAW,CAAC,CAAC;QACzE,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,IACd,OAAO,EAAE,OAAe,EACxB,gBAAgB,EAAE,gBAAwB,EAC1C,OAAO,EAAE,OAAmB,EAC5B,QAAQ,EAAE,mBAAmB,KACzB,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -16,18 +16,11 @@
16
16
  * under the License.
17
17
  */
18
18
  import { AsgardeoContextProps as AsgardeoReactContextProps } from '@asgardeo/react';
19
- import { EmbeddedFlowExecuteRequestConfig, EmbeddedSignInFlowHandleRequestPayload, User } from '@asgardeo/node';
20
19
  import { Context } from 'react';
21
20
  /**
22
21
  * Props interface of {@link AsgardeoContext}
23
22
  */
24
- export type AsgardeoContextProps = Partial<AsgardeoReactContextProps> & {
25
- user?: User | null;
26
- isSignedIn?: boolean;
27
- isLoading?: boolean;
28
- signIn?: (payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig) => void;
29
- signOut?: () => void;
30
- };
23
+ export type AsgardeoContextProps = Partial<AsgardeoReactContextProps>;
31
24
  /**
32
25
  * Context object for managing the Authentication flow builder core context.
33
26
  */
@@ -20,7 +20,19 @@ import { createContext } from 'react';
20
20
  /**
21
21
  * Context object for managing the Authentication flow builder core context.
22
22
  */
23
- const AsgardeoContext = createContext({});
23
+ const AsgardeoContext = createContext({
24
+ signInUrl: undefined,
25
+ signUpUrl: undefined,
26
+ afterSignInUrl: undefined,
27
+ baseUrl: undefined,
28
+ isInitialized: false,
29
+ isLoading: true,
30
+ isSignedIn: false,
31
+ signIn: null,
32
+ signOut: null,
33
+ signUp: null,
34
+ user: null,
35
+ });
24
36
  AsgardeoContext.displayName = 'AsgardeoContext';
25
37
  export default AsgardeoContext;
26
38
  //# sourceMappingURL=AsgardeoContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsgardeoContext.js","sourceRoot":"","sources":["../../../../src/client/contexts/Asgardeo/AsgardeoContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAIb,OAAO,EAAU,aAAa,EAAC,MAAM,OAAO,CAAC;AAa7C;;GAEG;AACH,MAAM,eAAe,GAAyC,aAAa,CAA8B,EAAE,CAAC,CAAC;AAE7G,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEhD,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"AsgardeoContext.js","sourceRoot":"","sources":["../../../../src/client/contexts/Asgardeo/AsgardeoContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAIb,OAAO,EAAU,aAAa,EAAC,MAAM,OAAO,CAAC;AAO7C;;GAEG;AACH,MAAM,eAAe,GAAyC,aAAa,CAA8B;IACvG,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE,SAAS;IAClB,aAAa,EAAE,KAAK;IACpB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEhD,eAAe,eAAe,CAAC"}
@@ -15,15 +15,25 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
+ import { User, UserProfile } from '@asgardeo/node';
19
+ import { AsgardeoProviderProps } from '@asgardeo/react';
18
20
  import { FC, PropsWithChildren } from 'react';
21
+ import { AsgardeoContextProps } from './AsgardeoContext';
19
22
  /**
20
23
  * Props interface of {@link AsgardeoClientProvider}
21
24
  */
22
- export type AsgardeoClientProviderProps = {
23
- /**
24
- * Preferences for theming, i18n, and other UI customizations.
25
- */
26
- preferences?: any;
25
+ export type AsgardeoClientProviderProps = Partial<Omit<AsgardeoProviderProps, 'baseUrl' | 'clientId'>> & Pick<AsgardeoProviderProps, 'baseUrl' | 'clientId'> & {
26
+ signOut: AsgardeoContextProps['signOut'];
27
+ signIn: AsgardeoContextProps['signIn'];
28
+ signUp: AsgardeoContextProps['signUp'];
29
+ handleOAuthCallback: (code: string, state: string, sessionState?: string) => Promise<{
30
+ success: boolean;
31
+ error?: string;
32
+ redirectUrl?: string;
33
+ }>;
34
+ isSignedIn: boolean;
35
+ userProfile: UserProfile;
36
+ user: User | null;
27
37
  };
28
38
  declare const AsgardeoClientProvider: FC<PropsWithChildren<AsgardeoClientProviderProps>>;
29
39
  export default AsgardeoClientProvider;