@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
package/dist/cjs/index.js CHANGED
@@ -34,26 +34,41 @@ __export(index_exports, {
34
34
  SignIn: () => import_SignIn.default,
35
35
  SignInButton: () => import_SignInButton.default,
36
36
  SignOutButton: () => import_SignOutButton.default,
37
+ SignUp: () => import_SignUp.default,
38
+ SignUpButton: () => import_SignUpButton.default,
37
39
  SignedIn: () => import_SignedIn.default,
38
40
  SignedInProps: () => import_SignedIn2.SignedInProps,
39
41
  SignedOut: () => import_SignedOut.default,
40
42
  SignedOutProps: () => import_SignedOut2.SignedOutProps,
41
43
  User: () => import_User.default,
42
- isSignedIn: () => import_isSignedIn.default
44
+ UserDropdown: () => import_UserDropdown.default,
45
+ UserProfile: () => import_UserProfile.default,
46
+ asgardeoMiddleware: () => import_asgardeoMiddleware.default,
47
+ handleOAuthCallback: () => import_handleOAuthCallbackAction.default,
48
+ isSignedIn: () => import_isSignedIn.default,
49
+ useAsgardeo: () => import_useAsgardeo.default
43
50
  });
44
51
  module.exports = __toCommonJS(index_exports);
45
52
  var import_AsgardeoProvider = __toESM(require("./server/AsgardeoProvider"), 1);
46
53
  __reExport(index_exports, require("./server/AsgardeoProvider"), module.exports);
54
+ var import_useAsgardeo = __toESM(require("./client/contexts/Asgardeo/useAsgardeo"), 1);
55
+ __reExport(index_exports, require("./client/contexts/Asgardeo/useAsgardeo"), module.exports);
47
56
  var import_isSignedIn = __toESM(require("./server/actions/isSignedIn"), 1);
57
+ var import_handleOAuthCallbackAction = __toESM(require("./server/actions/handleOAuthCallbackAction"), 1);
48
58
  var import_SignedIn = __toESM(require("./client/components/control/SignedIn/SignedIn"), 1);
49
59
  var import_SignedIn2 = require("./client/components/control/SignedIn/SignedIn");
50
60
  var import_SignedOut = __toESM(require("./client/components/control/SignedOut/SignedOut"), 1);
51
61
  var import_SignedOut2 = require("./client/components/control/SignedOut/SignedOut");
52
62
  var import_SignInButton = __toESM(require("./client/components/actions/SignInButton/SignInButton"), 1);
63
+ var import_SignUpButton = __toESM(require("./client/components/actions/SignUpButton/SignUpButton"), 1);
53
64
  var import_SignIn = __toESM(require("./client/components/presentation/SignIn/SignIn"), 1);
54
65
  var import_SignOutButton = __toESM(require("./client/components/actions/SignOutButton/SignOutButton"), 1);
55
66
  var import_User = __toESM(require("./client/components/presentation/User/User"), 1);
67
+ var import_SignUp = __toESM(require("./client/components/presentation/SignUp/SignUp"), 1);
68
+ var import_UserDropdown = __toESM(require("./client/components/presentation/UserDropdown/UserDropdown"), 1);
69
+ var import_UserProfile = __toESM(require("./client/components/presentation/UserProfile/UserProfile"), 1);
56
70
  var import_AsgardeoNextClient = __toESM(require("./AsgardeoNextClient"), 1);
71
+ var import_asgardeoMiddleware = __toESM(require("./middleware/asgardeoMiddleware"), 1);
57
72
  // Annotate the CommonJS export names for ESM import in node:
58
73
  0 && (module.exports = {
59
74
  AsgardeoNext,
@@ -61,12 +76,20 @@ var import_AsgardeoNextClient = __toESM(require("./AsgardeoNextClient"), 1);
61
76
  SignIn,
62
77
  SignInButton,
63
78
  SignOutButton,
79
+ SignUp,
80
+ SignUpButton,
64
81
  SignedIn,
65
82
  SignedInProps,
66
83
  SignedOut,
67
84
  SignedOutProps,
68
85
  User,
86
+ UserDropdown,
87
+ UserProfile,
88
+ asgardeoMiddleware,
89
+ handleOAuthCallback,
69
90
  isSignedIn,
70
- ...require("./server/AsgardeoProvider")
91
+ useAsgardeo,
92
+ ...require("./server/AsgardeoProvider"),
93
+ ...require("./client/contexts/Asgardeo/useAsgardeo")
71
94
  });
72
95
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "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\nexport {default as AsgardeoProvider} from './server/AsgardeoProvider';\nexport * from './server/AsgardeoProvider';\n\nexport {default as isSignedIn} from './server/actions/isSignedIn';\n\nexport {default as SignedIn} from './client/components/control/SignedIn/SignedIn';\nexport {SignedInProps} from './client/components/control/SignedIn/SignedIn';\n\nexport {default as SignedOut} from './client/components/control/SignedOut/SignedOut';\nexport {SignedOutProps} from './client/components/control/SignedOut/SignedOut';\n\nexport {default as SignInButton} from './client/components/actions/SignInButton/SignInButton';\nexport type {SignInButtonProps} from './client/components/actions/SignInButton/SignInButton';\n\nexport {default as SignIn} from './client/components/presentation/SignIn/SignIn';\nexport type {SignInProps} from './client/components/presentation/SignIn/SignIn';\n\nexport {default as SignOutButton} from './client/components/actions/SignOutButton/SignOutButton';\nexport type {SignOutButtonProps} from './client/components/actions/SignOutButton/SignOutButton';\n\nexport {default as User} from './client/components/presentation/User/User';\nexport type {UserProps} from './client/components/presentation/User/User';\n\nexport {default as AsgardeoNext} from './AsgardeoNextClient';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,8BAA0C;AAC1C,0BAAc,sCAnBd;AAqBA,wBAAoC;AAEpC,sBAAkC;AAClC,IAAAA,mBAA4B;AAE5B,uBAAmC;AACnC,IAAAC,oBAA6B;AAE7B,0BAAsC;AAGtC,oBAAgC;AAGhC,2BAAuC;AAGvC,kBAA8B;AAG9B,gCAAsC;",
4
+ "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\nexport {default as AsgardeoProvider} from './server/AsgardeoProvider';\nexport * from './server/AsgardeoProvider';\n\nexport {default as useAsgardeo} from './client/contexts/Asgardeo/useAsgardeo';\nexport * from './client/contexts/Asgardeo/useAsgardeo';\n\nexport {default as isSignedIn} from './server/actions/isSignedIn';\n\nexport {default as handleOAuthCallback} from './server/actions/handleOAuthCallbackAction';\n\nexport {default as SignedIn} from './client/components/control/SignedIn/SignedIn';\nexport {SignedInProps} from './client/components/control/SignedIn/SignedIn';\n\nexport {default as SignedOut} from './client/components/control/SignedOut/SignedOut';\nexport {SignedOutProps} from './client/components/control/SignedOut/SignedOut';\n\nexport {default as SignInButton} from './client/components/actions/SignInButton/SignInButton';\nexport type {SignInButtonProps} from './client/components/actions/SignInButton/SignInButton';\n\nexport {default as SignUpButton} from './client/components/actions/SignUpButton/SignUpButton';\nexport type {SignUpButtonProps} from './client/components/actions/SignUpButton/SignUpButton';\n\nexport {default as SignIn} from './client/components/presentation/SignIn/SignIn';\nexport type {SignInProps} from './client/components/presentation/SignIn/SignIn';\n\nexport {default as SignOutButton} from './client/components/actions/SignOutButton/SignOutButton';\nexport type {SignOutButtonProps} from './client/components/actions/SignOutButton/SignOutButton';\n\nexport {default as User} from './client/components/presentation/User/User';\nexport type {UserProps} from './client/components/presentation/User/User';\n\nexport {default as SignUp} from './client/components/presentation/SignUp/SignUp';\nexport type {SignUpProps} from './client/components/presentation/SignUp/SignUp';\n\nexport {default as UserDropdown} from './client/components/presentation/UserDropdown/UserDropdown';\nexport type {UserDropdownProps} from './client/components/presentation/UserDropdown/UserDropdown';\n\nexport {default as UserProfile} from './client/components/presentation/UserProfile/UserProfile';\nexport type {UserProfileProps} from './client/components/presentation/UserProfile/UserProfile';\n\nexport {default as AsgardeoNext} from './AsgardeoNextClient';\n\nexport {default as asgardeoMiddleware} from './middleware/asgardeoMiddleware';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,8BAA0C;AAC1C,0BAAc,sCAnBd;AAqBA,yBAAqC;AACrC,0BAAc,mDAtBd;AAwBA,wBAAoC;AAEpC,uCAA6C;AAE7C,sBAAkC;AAClC,IAAAA,mBAA4B;AAE5B,uBAAmC;AACnC,IAAAC,oBAA6B;AAE7B,0BAAsC;AAGtC,0BAAsC;AAGtC,oBAAgC;AAGhC,2BAAuC;AAGvC,kBAA8B;AAG9B,oBAAgC;AAGhC,0BAAsC;AAGtC,yBAAqC;AAGrC,gCAAsC;AAEtC,gCAA4C;",
6
6
  "names": ["import_SignedIn", "import_SignedOut"]
7
7
  }
@@ -22,7 +22,7 @@ import { BaseSignInButtonProps } from '@asgardeo/react';
22
22
  */
23
23
  export type SignInButtonProps = BaseSignInButtonProps;
24
24
  /**
25
- * SignInButton component that supports both render props and traditional props patterns for Next.js.
25
+ * SignInButton component that uses server actions for authentication in Next.js.
26
26
  *
27
27
  * @example Using render props
28
28
  * ```tsx
@@ -41,7 +41,7 @@ export type SignInButtonProps = BaseSignInButtonProps;
41
41
  * ```
42
42
  *
43
43
  * @remarks
44
- * In Next.js with server actions, the sign-in is handled via form submission.
44
+ * In Next.js with server actions, the sign-in is handled via the server action.
45
45
  * When using render props, the custom button should use `type="submit"` instead of `onClick={signIn}`.
46
46
  * The `signIn` function in render props is provided for API consistency but should not be used directly.
47
47
  */
@@ -17,11 +17,13 @@
17
17
  */
18
18
  'use client';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
- import { forwardRef } from 'react';
21
- import InternalAuthAPIRoutesConfig from '../../../../configs/InternalAuthAPIRoutesConfig';
22
- import { BaseSignInButton } from '@asgardeo/react';
20
+ import { forwardRef, useState } from 'react';
21
+ import { AsgardeoRuntimeError } from '@asgardeo/node';
22
+ import { BaseSignInButton, useTranslation } from '@asgardeo/react';
23
+ import useAsgardeo from '../../../../client/contexts/Asgardeo/useAsgardeo';
24
+ import { useRouter } from 'next/navigation';
23
25
  /**
24
- * SignInButton component that supports both render props and traditional props patterns for Next.js.
26
+ * SignInButton component that uses server actions for authentication in Next.js.
25
27
  *
26
28
  * @example Using render props
27
29
  * ```tsx
@@ -40,12 +42,37 @@ import { BaseSignInButton } from '@asgardeo/react';
40
42
  * ```
41
43
  *
42
44
  * @remarks
43
- * In Next.js with server actions, the sign-in is handled via form submission.
45
+ * In Next.js with server actions, the sign-in is handled via the server action.
44
46
  * When using render props, the custom button should use `type="submit"` instead of `onClick={signIn}`.
45
47
  * The `signIn` function in render props is provided for API consistency but should not be used directly.
46
48
  */
47
- const SignInButton = forwardRef(({ className, style, ...rest }, ref) => {
48
- return (_jsx("form", { action: InternalAuthAPIRoutesConfig.signIn, children: _jsx(BaseSignInButton, { className: className, style: style, ref: ref, type: "submit", ...rest }) }));
49
+ const SignInButton = forwardRef(({ className, style, children, preferences, onClick, ...rest }, ref) => {
50
+ const { signIn, signInUrl } = useAsgardeo();
51
+ const router = useRouter();
52
+ const { t } = useTranslation(preferences?.i18n);
53
+ const [isLoading, setIsLoading] = useState(false);
54
+ const handleOnClick = async (e) => {
55
+ try {
56
+ setIsLoading(true);
57
+ // If a custom `signInUrl` is provided, use it for navigation.
58
+ if (signInUrl) {
59
+ router.push(signInUrl);
60
+ }
61
+ else {
62
+ await signIn();
63
+ }
64
+ if (onClick) {
65
+ onClick(e);
66
+ }
67
+ }
68
+ catch (error) {
69
+ throw new AsgardeoRuntimeError(`Sign in failed: ${error instanceof Error ? error.message : String(error)}`, 'SignInButton-handleSignIn-RuntimeError-001', 'nextjs', 'Something went wrong while trying to sign in. Please try again later.');
70
+ }
71
+ finally {
72
+ setIsLoading(false);
73
+ }
74
+ };
75
+ return (_jsx(BaseSignInButton, { className: className, style: style, ref: ref, preferences: preferences, onClick: handleOnClick, ...rest, children: children ?? t('elements.buttons.signIn') }));
49
76
  });
50
77
  SignInButton.displayName = 'SignInButton';
51
78
  export default SignInButton;
@@ -1 +1 @@
1
- {"version":3,"file":"SignInButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAC,UAAU,EAA8D,MAAM,OAAO,CAAC;AAC9F,OAAO,2BAA2B,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAC,gBAAgB,EAAwB,MAAM,iBAAiB,CAAC;AAOxE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,YAAY,GAAG,UAAU,CAC7B,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAoB,EAAE,GAA2B,EAAgB,EAAE;IA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AE;QAC9E,IAAI,CAAC;YACH,YAAY,CAAC,IAAI,CAAC,CAAC;YAEnB,8DAA8D;YAC9D,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,EAAE,CAAC;YACjB,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,oBAAoB,CAC5B,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC3E,4CAA4C,EAC5C,QAAQ,EACR,uEAAuE,CACxE,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,IACf,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,aAAa,KAClB,IAAI,YAEP,QAAQ,IAAI,CAAC,CAAC,yBAAyB,CAAC,GACxB,CACpB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,eAAe,YAAY,CAAC"}
@@ -15,7 +15,6 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FC, PropsWithChildren } from 'react';
19
18
  import { BaseSignOutButtonProps } from '@asgardeo/react';
20
19
  /**
21
20
  * Interface for SignInButton component props.
@@ -38,5 +37,5 @@ export type SignOutButtonProps = BaseSignOutButtonProps;
38
37
  * }
39
38
  * ```
40
39
  */
41
- declare const SignOutButton: FC<PropsWithChildren<SignOutButtonProps>>;
40
+ declare const SignOutButton: import("react").ForwardRefExoticComponent<BaseSignOutButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
42
41
  export default SignOutButton;
@@ -17,9 +17,10 @@
17
17
  */
18
18
  'use client';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
- import { forwardRef } from 'react';
21
- import InternalAuthAPIRoutesConfig from '../../../../configs/InternalAuthAPIRoutesConfig';
22
- import { BaseSignOutButton } from '@asgardeo/react';
20
+ import { forwardRef, useState } from 'react';
21
+ import { BaseSignOutButton, useTranslation } from '@asgardeo/react';
22
+ import { AsgardeoRuntimeError } from '@asgardeo/node';
23
+ import useAsgardeo from '../../../../client/contexts/Asgardeo/useAsgardeo';
23
24
  /**
24
25
  * SignInButton component. This button initiates the sign-in process when clicked.
25
26
  *
@@ -37,6 +38,26 @@ import { BaseSignOutButton } from '@asgardeo/react';
37
38
  * }
38
39
  * ```
39
40
  */
40
- const SignOutButton = forwardRef(({ className, style, ...rest }, ref) => (_jsx("form", { action: InternalAuthAPIRoutesConfig.signOut, children: _jsx(BaseSignOutButton, { className: className, style: style, ref: ref, type: "submit", ...rest }) })));
41
+ const SignOutButton = forwardRef(({ className, style, preferences, onClick, children, ...rest }, ref) => {
42
+ const { signOut } = useAsgardeo();
43
+ const { t } = useTranslation(preferences?.i18n);
44
+ const [isLoading, setIsLoading] = useState(false);
45
+ const handleOnClick = async (e) => {
46
+ try {
47
+ setIsLoading(true);
48
+ await signOut();
49
+ if (onClick) {
50
+ onClick(e);
51
+ }
52
+ }
53
+ catch (error) {
54
+ throw new AsgardeoRuntimeError(`Sign out failed: ${error instanceof Error ? error.message : String(error)}`, 'SignOutButton-handleOnClick-RuntimeError-001', 'next', 'Something went wrong while trying to sign out. Please try again later.');
55
+ }
56
+ finally {
57
+ setIsLoading(false);
58
+ }
59
+ };
60
+ return (_jsx(BaseSignOutButton, { ref: ref, onClick: handleOnClick, isLoading: isLoading, preferences: preferences, ...rest, children: children ?? t('elements.buttons.signOut') }));
61
+ });
41
62
  export default SignOutButton;
42
63
  //# sourceMappingURL=SignOutButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignOutButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAK,UAAU,EAAuC,MAAM,OAAO,CAAC;AAC3E,OAAO,2BAA2B,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAC,iBAAiB,EAAyB,MAAM,iBAAiB,CAAC;AAO1E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,aAAa,GAA8C,UAAU,CAIzE,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAwC,EAAE,GAA2B,EAAgB,EAAE,CAAC,CACjH,eAAM,MAAM,EAAE,2BAA2B,CAAC,OAAO,YAC/C,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAC,QAAQ,KAAK,IAAI,GAAI,GACtF,CACR,CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"SignOutButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAK,UAAU,EAAwC,QAAQ,EAAa,MAAM,OAAO,CAAC;AACjG,OAAO,EAAC,iBAAiB,EAA0B,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,WAAW,MAAM,kDAAkD,CAAC;AAO3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,aAAa,GAAG,UAAU,CAC9B,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAqB,EAAE,GAA2B,EAAgB,EAAE;IAC7H,MAAM,EAAC,OAAO,EAAC,GAAG,WAAW,EAAE,CAAC;IAChC,MAAM,EAAC,CAAC,EAAC,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAE9C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,MAAM,aAAa,GAAG,KAAK,EAAE,CAAgC,EAAiB,EAAE;QAC9E,IAAI,CAAC;YACH,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,MAAM,OAAO,EAAE,CAAC;YAEhB,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,oBAAoB,CAC5B,oBAAoB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC5E,8CAA8C,EAC9C,MAAM,EACN,wEAAwE,CACzE,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,iBAAiB,IAChB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,KACpB,IAAI,YAEP,QAAQ,IAAI,CAAC,CAAC,0BAA0B,CAAC,GACxB,CACrB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -15,28 +15,52 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { FC, PropsWithChildren } from 'react';
18
+ import { ForwardRefExoticComponent, RefAttributes } from 'react';
19
19
  import { BaseSignUpButtonProps } from '@asgardeo/react';
20
20
  /**
21
- * Interface for SignInButton component props.
21
+ * Props interface of {@link SignUpButton}
22
22
  */
23
23
  export type SignUpButtonProps = BaseSignUpButtonProps;
24
24
  /**
25
- * SignInButton component. This button initiates the sign-in process when clicked.
25
+ * SignUpButton component that supports both render props and traditional props patterns.
26
+ * It redirects the user to the Asgardeo sign-up page configured for the application.
26
27
  *
27
- * @example
28
+ * @remarks This component is only supported in browser based React applications (CSR).
29
+ *
30
+ * @example Using render props pattern
31
+ * ```tsx
32
+ * <SignUpButton>
33
+ * {({ signUp, isLoading }) => (
34
+ * <button onClick={signUp} disabled={isLoading}>
35
+ * {isLoading ? 'Creating Account...' : 'Create Account'}
36
+ * </button>
37
+ * )}
38
+ * </SignUpButton>
39
+ * ```
40
+ *
41
+ * @example Using traditional props pattern
28
42
  * ```tsx
29
- * import { SignInButton } from '@asgardeo/auth-react';
43
+ * <SignUpButton className="custom-button">Create Account</SignUpButton>
44
+ * ```
30
45
  *
31
- * const App = () => {
32
- * const buttonRef = useRef<HTMLButtonElement>(null);
33
- * return (
34
- * <SignInButton ref={buttonRef} className="custom-class" style={{ backgroundColor: 'blue' }}>
35
- * Sign In
36
- * </SignInButton>
37
- * );
38
- * }
46
+ * @example Using component-level preferences
47
+ * ```tsx
48
+ * <SignUpButton
49
+ * preferences={{
50
+ * i18n: {
51
+ * bundles: {
52
+ * 'en-US': {
53
+ * translations: {
54
+ * 'buttons.signUp': 'Custom Sign Up Text'
55
+ * }
56
+ * }
57
+ * }
58
+ * }
59
+ * }}
60
+ * >
61
+ * Custom Sign Up
62
+ * </SignUpButton>
39
63
  * ```
40
64
  */
41
- declare const SignUpButton: FC<PropsWithChildren<SignUpButtonProps>>;
65
+ declare const SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>>;
42
66
  export default SignUpButton;
@@ -17,26 +17,80 @@
17
17
  */
18
18
  'use client';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
- import { forwardRef } from 'react';
21
- import InternalAuthAPIRoutesConfig from '../../../../configs/InternalAuthAPIRoutesConfig';
22
- import { BaseSignUpButton } from '@asgardeo/react';
20
+ import { AsgardeoRuntimeError } from '@asgardeo/node';
21
+ import { forwardRef, useState } from 'react';
22
+ import { BaseSignUpButton, useTranslation } from '@asgardeo/react';
23
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
24
+ import { useRouter } from 'next/navigation';
23
25
  /**
24
- * SignInButton component. This button initiates the sign-in process when clicked.
26
+ * SignUpButton component that supports both render props and traditional props patterns.
27
+ * It redirects the user to the Asgardeo sign-up page configured for the application.
25
28
  *
26
- * @example
29
+ * @remarks This component is only supported in browser based React applications (CSR).
30
+ *
31
+ * @example Using render props pattern
32
+ * ```tsx
33
+ * <SignUpButton>
34
+ * {({ signUp, isLoading }) => (
35
+ * <button onClick={signUp} disabled={isLoading}>
36
+ * {isLoading ? 'Creating Account...' : 'Create Account'}
37
+ * </button>
38
+ * )}
39
+ * </SignUpButton>
40
+ * ```
41
+ *
42
+ * @example Using traditional props pattern
27
43
  * ```tsx
28
- * import { SignInButton } from '@asgardeo/auth-react';
44
+ * <SignUpButton className="custom-button">Create Account</SignUpButton>
45
+ * ```
29
46
  *
30
- * const App = () => {
31
- * const buttonRef = useRef<HTMLButtonElement>(null);
32
- * return (
33
- * <SignInButton ref={buttonRef} className="custom-class" style={{ backgroundColor: 'blue' }}>
34
- * Sign In
35
- * </SignInButton>
36
- * );
37
- * }
47
+ * @example Using component-level preferences
48
+ * ```tsx
49
+ * <SignUpButton
50
+ * preferences={{
51
+ * i18n: {
52
+ * bundles: {
53
+ * 'en-US': {
54
+ * translations: {
55
+ * 'buttons.signUp': 'Custom Sign Up Text'
56
+ * }
57
+ * }
58
+ * }
59
+ * }
60
+ * }}
61
+ * >
62
+ * Custom Sign Up
63
+ * </SignUpButton>
38
64
  * ```
39
65
  */
40
- const SignUpButton = forwardRef(({ className, style, ...rest }, ref) => (_jsx("form", { action: InternalAuthAPIRoutesConfig.signUp, children: _jsx(BaseSignUpButton, { className: className, style: style, ref: ref, type: "submit", ...rest }) })));
66
+ const SignUpButton = forwardRef(({ children, onClick, preferences, ...rest }, ref) => {
67
+ const { signUp, signUpUrl } = useAsgardeo();
68
+ const router = useRouter();
69
+ const { t } = useTranslation(preferences?.i18n);
70
+ const [isLoading, setIsLoading] = useState(false);
71
+ const handleSignUp = async (e) => {
72
+ try {
73
+ setIsLoading(true);
74
+ // If a custom `signUpUrl` is provided, use it for navigation.
75
+ if (signUpUrl) {
76
+ router.push(signUpUrl);
77
+ }
78
+ else {
79
+ await signUp();
80
+ }
81
+ if (onClick) {
82
+ onClick(e);
83
+ }
84
+ }
85
+ catch (error) {
86
+ throw new AsgardeoRuntimeError(`Sign up failed: ${error instanceof Error ? error.message : String(error)}`, 'SignUpButton-handleSignUp-RuntimeError-001', 'nextjs', 'Something went wrong while trying to sign up. Please try again later.');
87
+ }
88
+ finally {
89
+ setIsLoading(false);
90
+ }
91
+ };
92
+ return (_jsx(BaseSignUpButton, { ref: ref, onClick: handleSignUp, isLoading: isLoading, signUp: handleSignUp, preferences: preferences, ...rest, children: children ?? t('elements.buttons.signUp') }));
93
+ });
94
+ SignUpButton.displayName = 'SignUpButton';
41
95
  export default SignUpButton;
42
96
  //# sourceMappingURL=SignUpButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignUpButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAK,UAAU,EAAuC,MAAM,OAAO,CAAC;AAC3E,OAAO,2BAA2B,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAC,gBAAgB,EAAwB,MAAM,iBAAiB,CAAC;AAOxE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,YAAY,GAA6C,UAAU,CAIvE,CAAC,EAAC,SAAS,EAAE,KAA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9E,IAAI,CAAC;YACH,YAAY,CAAC,IAAI,CAAC,CAAC;YAEnB,8DAA8D;YAC9D,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,EAAE,CAAC;YACjB,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,CAAkC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,oBAAoB,CAC5B,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC3E,4CAA4C,EAC5C,QAAQ,EACR,uEAAuE,CACxE,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,IACf,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,KACpB,IAAI,YAEP,QAAQ,IAAI,CAAC,CAAC,yBAAyB,CAAC,GACxB,CACpB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,eAAe,YAAY,CAAC"}
@@ -17,8 +17,7 @@
17
17
  */
18
18
  'use client';
19
19
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
20
- import { useEffect, useState } from 'react';
21
- import isSignedIn from '../../../../server/actions/isSignedIn';
20
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
22
21
  /**
23
22
  * A component that only renders its children when the user is signed in.
24
23
  *
@@ -36,21 +35,8 @@ import isSignedIn from '../../../../server/actions/isSignedIn';
36
35
  * ```
37
36
  */
38
37
  const SignedIn = ({ children, fallback = null, }) => {
39
- const [isSignedInSync, setIsSignedInSync] = useState(null);
40
- useEffect(() => {
41
- (async () => {
42
- try {
43
- const result = await isSignedIn();
44
- setIsSignedInSync(result);
45
- }
46
- catch (error) {
47
- setIsSignedInSync(false);
48
- }
49
- })();
50
- }, []);
51
- if (isSignedInSync === null)
52
- return null;
53
- return _jsx(_Fragment, { children: isSignedInSync ? children : fallback });
38
+ const { isSignedIn } = useAsgardeo();
39
+ return _jsx(_Fragment, { children: isSignedIn ? children : fallback });
54
40
  };
55
41
  export default SignedIn;
56
42
  //# sourceMappingURL=SignedIn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignedIn.js","sourceRoot":"","sources":["../../../../../src/client/components/control/SignedIn/SignedIn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAmC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAY/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,QAAQ,GAAyC,CAAC,EACtD,QAAQ,EACR,QAAQ,GAAG,IAAI,GACkB,EAAE,EAAE;IACrC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACb,CAAC,KAAK,IAAmB,EAAE;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAY,MAAM,UAAU,EAAE,CAAC;gBAE3C,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,cAAc,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEzC,OAAO,4BAAG,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAI,CAAC;AACrD,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"SignedIn.js","sourceRoot":"","sources":["../../../../../src/client/components/control/SignedIn/SignedIn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAGb,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAYjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,QAAQ,GAAyC,CAAC,EACtD,QAAQ,EACR,QAAQ,GAAG,IAAI,GACkB,EAAE,EAAE;IACrC,MAAM,EAAC,UAAU,EAAC,GAAG,WAAW,EAAE,CAAC;IAEnC,OAAO,4BAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAI,CAAC;AACjD,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -17,8 +17,7 @@
17
17
  */
18
18
  'use client';
19
19
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
20
- import { useEffect, useState } from 'react';
21
- import isSignedIn from '../../../../server/actions/isSignedIn';
20
+ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
22
21
  /**
23
22
  * A component that only renders its children when the user is signed out.
24
23
  *
@@ -36,21 +35,8 @@ import isSignedIn from '../../../../server/actions/isSignedIn';
36
35
  * ```
37
36
  */
38
37
  const SignedOut = ({ children, fallback = null, }) => {
39
- const [isSignedInSync, setIsSignedInSync] = useState(null);
40
- useEffect(() => {
41
- (async () => {
42
- try {
43
- const result = await isSignedIn();
44
- setIsSignedInSync(result);
45
- }
46
- catch (error) {
47
- setIsSignedInSync(false);
48
- }
49
- })();
50
- }, []);
51
- if (isSignedInSync === null)
52
- return null;
53
- return _jsx(_Fragment, { children: !isSignedInSync ? children : fallback });
38
+ const { isSignedIn } = useAsgardeo();
39
+ return _jsx(_Fragment, { children: !isSignedIn ? children : fallback });
54
40
  };
55
41
  export default SignedOut;
56
42
  //# sourceMappingURL=SignedOut.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignedOut.js","sourceRoot":"","sources":["../../../../../src/client/components/control/SignedOut/SignedOut.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAmC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAY/D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,SAAS,GAA0C,CAAC,EACxD,QAAQ,EACR,QAAQ,GAAG,IAAI,GACmB,EAAE,EAAE;IACtC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACb,CAAC,KAAK,IAAmB,EAAE;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAY,MAAM,UAAU,EAAE,CAAC;gBAE3C,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,cAAc,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEzC,OAAO,4BAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAI,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"SignedOut.js","sourceRoot":"","sources":["../../../../../src/client/components/control/SignedOut/SignedOut.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAGb,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAYjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,SAAS,GAA0C,CAAC,EACxD,QAAQ,EACR,QAAQ,GAAG,IAAI,GACmB,EAAE,EAAE;IACtC,MAAM,EAAC,UAAU,EAAC,GAAG,WAAW,EAAE,CAAC;IAEnC,OAAO,4BAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAI,CAAC;AAClD,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -21,7 +21,7 @@ import { FC } from 'react';
21
21
  * Props for the SignIn component.
22
22
  * Extends BaseSignInProps for full compatibility with the React BaseSignIn component
23
23
  */
24
- export type SignInProps = BaseSignInProps;
24
+ export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onError' | 'variant' | 'size'>;
25
25
  /**
26
26
  * A SignIn component for Next.js that provides native authentication flow.
27
27
  * This component delegates to the BaseSignIn from @asgardeo/react and requires
@@ -62,8 +62,8 @@ import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
62
62
  * };
63
63
  * ```
64
64
  */
65
- const SignIn = ({ afterSignInUrl, className, onError, onFlowChange, onInitialize, onSubmit, onSuccess, size = 'medium', variant = 'outlined', ...rest }) => {
66
- const { signIn } = useAsgardeo();
65
+ const SignIn = ({ size = 'medium', variant = 'outlined', ...rest }) => {
66
+ const { signIn, afterSignInUrl } = useAsgardeo();
67
67
  const handleInitialize = async () => await signIn({
68
68
  flowId: '',
69
69
  selectedAuthenticator: {
@@ -71,11 +71,14 @@ const SignIn = ({ afterSignInUrl, className, onError, onFlowChange, onInitialize
71
71
  params: {},
72
72
  },
73
73
  });
74
- const handleOnSubmit = async (payload, request) => await signIn(payload, request);
75
- const handleError = (error) => {
76
- onError?.(error);
74
+ const handleOnSubmit = async (payload, request) => {
75
+ return await signIn(payload, request);
77
76
  };
78
- return (_jsx(BaseSignIn, { afterSignInUrl: afterSignInUrl, onInitialize: handleInitialize, onSubmit: handleOnSubmit, onSuccess: onSuccess, onError: handleError, onFlowChange: onFlowChange, className: className, size: size, variant: variant, ...rest }));
77
+ return (_jsx(BaseSignIn
78
+ // isLoading={isLoading || !isInitialized}
79
+ , {
80
+ // isLoading={isLoading || !isInitialized}
81
+ afterSignInUrl: afterSignInUrl, onInitialize: handleInitialize, onSubmit: handleOnSubmit, size: size, variant: variant, ...rest }));
79
82
  };
80
83
  SignIn.displayName = 'SignIn';
81
84
  export default SignIn;
@@ -1 +1 @@
1
- {"version":3,"file":"SignIn.js","sourceRoot":"","sources":["../../../../../src/client/components/presentation/SignIn/SignIn.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAQb,OAAO,EAAC,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AAE5D,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAQjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,MAAM,GAAoB,CAAC,EAC/B,cAAc,EACd,SAAS,EACT,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,UAAU,EACpB,GAAG,IAAI,EACK,EAAE,EAAE;IAChB,MAAM,EAAC,MAAM,EAAC,GAAG,WAAW,EAAE,CAAC;IAE/B,MAAM,gBAAgB,GAAG,KAAK,IAAiD,EAAE,CAC/E,MAAM,MAAM,CAAC;QACX,MAAM,EAAE,EAAE;QACV,qBAAqB,EAAE;YACrB,eAAe,EAAE,EAAE;YACnB,MAAM,EAAE,EAAE;SACX;KACF,CAAC,CAAC;IAEL,MAAM,cAAc,GAAG,KAAK,EAC1B,OAA+C,EAC/C,OAAyC,EACE,EAAE,CAAC,MAAM,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE/E,MAAM,WAAW,GAAG,CAAC,KAAY,EAAQ,EAAE;QACzC,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IAEF,OAAO,CACL,KAAC,UAAU;IACT,0CAA0C;;QAA1C,0CAA0C;QAC1C,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,KACZ,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE9B,eAAe,MAAM,CAAC"}
@@ -0,0 +1,55 @@
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 { BaseSignUpProps } from '@asgardeo/react';
20
+ /**
21
+ * Props for the SignUp component.
22
+ */
23
+ export type SignUpProps = BaseSignUpProps;
24
+ /**
25
+ * A styled SignUp component that provides embedded sign-up flow with pre-built styling.
26
+ * This component handles the API calls for sign-up and delegates UI logic to BaseSignUp.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * import { SignUp } from '@asgardeo/react';
31
+ *
32
+ * const App = () => {
33
+ * return (
34
+ * <SignUp
35
+ * onSuccess={(response) => {
36
+ * console.log('Sign-up successful:', response);
37
+ * // Handle successful sign-up (e.g., redirect, show confirmation)
38
+ * }}
39
+ * onError={(error) => {
40
+ * console.error('Sign-up failed:', error);
41
+ * }}
42
+ * onComplete={(redirectUrl) => {
43
+ * // Platform-specific redirect handling (e.g., Next.js router.push)
44
+ * router.push(redirectUrl); // or window.location.href = redirectUrl
45
+ * }}
46
+ * size="medium"
47
+ * variant="outlined"
48
+ * afterSignUpUrl="/welcome"
49
+ * />
50
+ * );
51
+ * };
52
+ * ```
53
+ */
54
+ declare const SignUp: FC<SignUpProps>;
55
+ export default SignUp;