@asgardeo/nextjs 0.0.2 → 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.
- package/README.md +68 -8
- package/dist/AsgardeoNextClient.d.ts +44 -9
- package/dist/AsgardeoNextClient.js +178 -85
- package/dist/AsgardeoNextClient.js.map +1 -1
- package/dist/cjs/index.js +28 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/client/components/actions/SignInButton/SignInButton.d.ts +2 -2
- package/dist/client/components/actions/SignInButton/SignInButton.js +34 -7
- package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -1
- package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts +1 -2
- package/dist/client/components/actions/SignOutButton/SignOutButton.js +25 -4
- package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -1
- package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts +38 -14
- package/dist/client/components/actions/SignUpButton/SignUpButton.js +69 -15
- package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -1
- package/dist/client/components/control/SignedIn/SignedIn.js +3 -17
- package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -1
- package/dist/client/components/control/SignedOut/SignedOut.js +3 -17
- package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -1
- package/dist/client/components/presentation/SignIn/SignIn.d.ts +69 -0
- package/dist/client/components/presentation/SignIn/SignIn.js +85 -0
- package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -0
- package/dist/client/components/presentation/SignUp/SignUp.d.ts +55 -0
- package/dist/client/components/presentation/SignUp/SignUp.js +70 -0
- package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts +105 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.js +106 -0
- package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.d.ts +49 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.js +57 -0
- package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -0
- package/dist/client/contexts/Asgardeo/AsgardeoContext.d.ts +1 -8
- package/dist/client/contexts/Asgardeo/AsgardeoContext.js +13 -1
- package/dist/client/contexts/Asgardeo/AsgardeoContext.js.map +1 -1
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.d.ts +15 -5
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.js +119 -37
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.js.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/middleware/asgardeoMiddleware.d.ts +63 -0
- package/dist/middleware/asgardeoMiddleware.js +115 -0
- package/dist/middleware/asgardeoMiddleware.js.map +1 -0
- package/dist/server/AsgardeoProvider.d.ts +6 -3
- package/dist/server/AsgardeoProvider.js +42 -3
- package/dist/server/AsgardeoProvider.js.map +1 -1
- package/dist/server/actions/getClientOrigin.d.ts +2 -0
- package/dist/server/actions/getClientOrigin.js +10 -0
- package/dist/server/actions/getClientOrigin.js.map +1 -0
- package/dist/server/actions/getUserAction.d.ts +35 -0
- package/dist/server/actions/getUserAction.js +35 -0
- package/dist/server/actions/getUserAction.js.map +1 -0
- package/dist/server/actions/getUserProfileAction.d.ts +40 -0
- package/dist/server/actions/getUserProfileAction.js +45 -0
- package/dist/server/actions/getUserProfileAction.js.map +1 -0
- package/dist/server/actions/handleOAuthCallbackAction.d.ts +33 -0
- package/dist/server/actions/handleOAuthCallbackAction.js +80 -0
- package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -0
- package/dist/server/actions/isSignedIn.d.ts +1 -1
- package/dist/server/actions/isSignedIn.js +5 -5
- package/dist/server/actions/isSignedIn.js.map +1 -1
- package/dist/server/actions/signInAction.d.ts +35 -0
- package/dist/server/actions/signInAction.js +71 -0
- package/dist/server/actions/signInAction.js.map +1 -0
- package/dist/server/actions/signOutAction.d.ts +25 -0
- package/dist/server/actions/signOutAction.js +33 -0
- package/dist/server/actions/signOutAction.js.map +1 -0
- package/dist/server/actions/signUpAction.d.ts +35 -0
- package/dist/server/actions/signUpAction.js +52 -0
- package/dist/server/actions/signUpAction.js.map +1 -0
- package/dist/server/actions/updateUserProfileAction.d.ts +36 -0
- package/dist/server/actions/updateUserProfileAction.js +41 -0
- package/dist/server/actions/updateUserProfileAction.js.map +1 -0
- package/dist/utils/decorateConfigWithNextEnv.js +5 -1
- package/dist/utils/decorateConfigWithNextEnv.js.map +1 -1
- package/package.json +14 -4
|
@@ -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
|
|
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
|
|
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
|
|
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
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"SignInButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GA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,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:
|
|
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
|
|
22
|
-
import {
|
|
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,
|
|
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;;AA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,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 {
|
|
18
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
19
19
|
import { BaseSignUpButtonProps } from '@asgardeo/react';
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Props interface of {@link SignUpButton}
|
|
22
22
|
*/
|
|
23
23
|
export type SignUpButtonProps = BaseSignUpButtonProps;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
43
|
+
* <SignUpButton className="custom-button">Create Account</SignUpButton>
|
|
44
|
+
* ```
|
|
30
45
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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:
|
|
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 {
|
|
21
|
-
import
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
44
|
+
* <SignUpButton className="custom-button">Create Account</SignUpButton>
|
|
45
|
+
* ```
|
|
29
46
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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(({
|
|
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,
|
|
1
|
+
{"version":3,"file":"SignUpButton.js","sourceRoot":"","sources":["../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;;AAEb,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAC,UAAU,EAA2E,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpH,OAAO,EAAC,gBAAgB,EAAyB,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,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
|
|
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
|
|
40
|
-
|
|
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;;
|
|
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
|
|
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
|
|
40
|
-
|
|
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;;
|
|
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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { BaseSignInProps } from '@asgardeo/react';
|
|
19
|
+
import { FC } from 'react';
|
|
20
|
+
/**
|
|
21
|
+
* Props for the SignIn component.
|
|
22
|
+
* Extends BaseSignInProps for full compatibility with the React BaseSignIn component
|
|
23
|
+
*/
|
|
24
|
+
export type SignInProps = Pick<BaseSignInProps, 'className' | 'onSuccess' | 'onError' | 'variant' | 'size'>;
|
|
25
|
+
/**
|
|
26
|
+
* A SignIn component for Next.js that provides native authentication flow.
|
|
27
|
+
* This component delegates to the BaseSignIn from @asgardeo/react and requires
|
|
28
|
+
* the API functions to be provided as props.
|
|
29
|
+
*
|
|
30
|
+
* @remarks This component requires the authentication API functions to be provided
|
|
31
|
+
* as props. For a complete working example, you'll need to implement the server-side
|
|
32
|
+
* authentication endpoints or use the traditional OAuth flow with SignInButton.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* import { SignIn } from '@asgardeo/nextjs';
|
|
37
|
+
* import { executeEmbeddedSignInFlow } from '@asgardeo/browser';
|
|
38
|
+
*
|
|
39
|
+
* const LoginPage = () => {
|
|
40
|
+
* const handleInitialize = async () => {
|
|
41
|
+
* return await executeEmbeddedSignInFlow({
|
|
42
|
+
* response_mode: 'direct',
|
|
43
|
+
* });
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* const handleSubmit = async (flow) => {
|
|
47
|
+
* return await executeEmbeddedSignInFlow({ flow });
|
|
48
|
+
* };
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <SignIn
|
|
52
|
+
* onInitialize={handleInitialize}
|
|
53
|
+
* onSubmit={handleSubmit}
|
|
54
|
+
* onSuccess={(authData) => {
|
|
55
|
+
* console.log('Authentication successful:', authData);
|
|
56
|
+
* }}
|
|
57
|
+
* onError={(error) => {
|
|
58
|
+
* console.error('Authentication failed:', error);
|
|
59
|
+
* }}
|
|
60
|
+
* size="medium"
|
|
61
|
+
* variant="outlined"
|
|
62
|
+
* afterSignInUrl="/dashboard"
|
|
63
|
+
* />
|
|
64
|
+
* );
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare const SignIn: FC<SignInProps>;
|
|
69
|
+
export default SignIn;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { BaseSignIn } from '@asgardeo/react';
|
|
21
|
+
import useAsgardeo from '../../../contexts/Asgardeo/useAsgardeo';
|
|
22
|
+
/**
|
|
23
|
+
* A SignIn component for Next.js that provides native authentication flow.
|
|
24
|
+
* This component delegates to the BaseSignIn from @asgardeo/react and requires
|
|
25
|
+
* the API functions to be provided as props.
|
|
26
|
+
*
|
|
27
|
+
* @remarks This component requires the authentication API functions to be provided
|
|
28
|
+
* as props. For a complete working example, you'll need to implement the server-side
|
|
29
|
+
* authentication endpoints or use the traditional OAuth flow with SignInButton.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { SignIn } from '@asgardeo/nextjs';
|
|
34
|
+
* import { executeEmbeddedSignInFlow } from '@asgardeo/browser';
|
|
35
|
+
*
|
|
36
|
+
* const LoginPage = () => {
|
|
37
|
+
* const handleInitialize = async () => {
|
|
38
|
+
* return await executeEmbeddedSignInFlow({
|
|
39
|
+
* response_mode: 'direct',
|
|
40
|
+
* });
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const handleSubmit = async (flow) => {
|
|
44
|
+
* return await executeEmbeddedSignInFlow({ flow });
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <SignIn
|
|
49
|
+
* onInitialize={handleInitialize}
|
|
50
|
+
* onSubmit={handleSubmit}
|
|
51
|
+
* onSuccess={(authData) => {
|
|
52
|
+
* console.log('Authentication successful:', authData);
|
|
53
|
+
* }}
|
|
54
|
+
* onError={(error) => {
|
|
55
|
+
* console.error('Authentication failed:', error);
|
|
56
|
+
* }}
|
|
57
|
+
* size="medium"
|
|
58
|
+
* variant="outlined"
|
|
59
|
+
* afterSignInUrl="/dashboard"
|
|
60
|
+
* />
|
|
61
|
+
* );
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
const SignIn = ({ size = 'medium', variant = 'outlined', ...rest }) => {
|
|
66
|
+
const { signIn, afterSignInUrl } = useAsgardeo();
|
|
67
|
+
const handleInitialize = async () => await signIn({
|
|
68
|
+
flowId: '',
|
|
69
|
+
selectedAuthenticator: {
|
|
70
|
+
authenticatorId: '',
|
|
71
|
+
params: {},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const handleOnSubmit = async (payload, request) => {
|
|
75
|
+
return await signIn(payload, request);
|
|
76
|
+
};
|
|
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 }));
|
|
82
|
+
};
|
|
83
|
+
SignIn.displayName = 'SignIn';
|
|
84
|
+
export default SignIn;
|
|
85
|
+
//# sourceMappingURL=SignIn.js.map
|
|
@@ -0,0 +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,EAAC,IAAI,GAAG,QAAQ,EAAE,OAAO,GAAG,UAAU,EAAE,GAAG,IAAI,EAAc,EAAE,EAAE;IAChG,MAAM,EAAC,MAAM,EAAE,cAAc,EAAC,GAAG,WAAW,EAAE,CAAC;IAE/C,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;QAC7C,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;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;
|