@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.
- package/README.md +68 -8
- package/dist/AsgardeoNextClient.d.ts +37 -8
- package/dist/AsgardeoNextClient.js +153 -138
- package/dist/AsgardeoNextClient.js.map +1 -1
- package/dist/cjs/index.js +25 -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 +1 -1
- package/dist/client/components/presentation/SignIn/SignIn.js +9 -6
- package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -1
- 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 +115 -49
- package/dist/client/contexts/Asgardeo/AsgardeoProvider.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -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
|
@@ -0,0 +1,35 @@
|
|
|
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 server';
|
|
19
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
|
+
/**
|
|
21
|
+
* Server action to get the current user.
|
|
22
|
+
* Returns the user profile if signed in.
|
|
23
|
+
*/
|
|
24
|
+
const getUserAction = async (sessionId) => {
|
|
25
|
+
try {
|
|
26
|
+
const client = AsgardeoNextClient.getInstance();
|
|
27
|
+
const user = await client.getUser(sessionId);
|
|
28
|
+
return { success: true, data: { user }, error: null };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return { success: false, data: { user: null }, error: 'Failed to get user' };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default getUserAction;
|
|
35
|
+
//# sourceMappingURL=getUserAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserAction.js","sourceRoot":"","sources":["../../../src/server/actions/getUserAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,aAAa,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE,KAAK,EAAE,oBAAoB,EAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { UserProfile } from '@asgardeo/node';
|
|
19
|
+
/**
|
|
20
|
+
* Server action to get the current user.
|
|
21
|
+
* Returns the user profile if signed in.
|
|
22
|
+
*/
|
|
23
|
+
declare const getUserProfileAction: (sessionId: string) => Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
data: {
|
|
26
|
+
userProfile: UserProfile;
|
|
27
|
+
};
|
|
28
|
+
error: null;
|
|
29
|
+
} | {
|
|
30
|
+
success: boolean;
|
|
31
|
+
data: {
|
|
32
|
+
userProfile: {
|
|
33
|
+
schemas: never[];
|
|
34
|
+
profile: {};
|
|
35
|
+
flattenedProfile: {};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
error: string;
|
|
39
|
+
}>;
|
|
40
|
+
export default getUserProfileAction;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 server';
|
|
19
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
|
+
/**
|
|
21
|
+
* Server action to get the current user.
|
|
22
|
+
* Returns the user profile if signed in.
|
|
23
|
+
*/
|
|
24
|
+
const getUserProfileAction = async (sessionId) => {
|
|
25
|
+
try {
|
|
26
|
+
const client = AsgardeoNextClient.getInstance();
|
|
27
|
+
const updatedProfile = await client.getUserProfile(sessionId);
|
|
28
|
+
return { success: true, data: { userProfile: updatedProfile }, error: null };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
data: {
|
|
34
|
+
userProfile: {
|
|
35
|
+
schemas: [],
|
|
36
|
+
profile: {},
|
|
37
|
+
flattenedProfile: {},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
error: 'Failed to get user profile',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export default getUserProfileAction;
|
|
45
|
+
//# sourceMappingURL=getUserProfileAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserProfileAction.js","sourceRoot":"","sources":["../../../src/server/actions/getUserProfileAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,oBAAoB,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,cAAc,GAAgB,MAAM,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC3E,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,WAAW,EAAE,cAAc,EAAC,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE;gBACJ,WAAW,EAAE;oBACX,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,EAAE;oBACX,gBAAgB,EAAE,EAAE;iBACrB;aACF;YACD,KAAK,EAAE,4BAA4B;SACpC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Server action to handle OAuth callback with authorization code.
|
|
20
|
+
* This action processes the authorization code received from the OAuth provider
|
|
21
|
+
* and exchanges it for tokens to complete the authentication flow.
|
|
22
|
+
*
|
|
23
|
+
* @param code - Authorization code from OAuth provider
|
|
24
|
+
* @param state - State parameter from OAuth provider for CSRF protection
|
|
25
|
+
* @param sessionState - Session state parameter from OAuth provider
|
|
26
|
+
* @returns Promise that resolves with success status and optional error message
|
|
27
|
+
*/
|
|
28
|
+
declare const handleOAuthCallbackAction: (code: string, state: string, sessionState?: string) => Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
error?: string;
|
|
31
|
+
redirectUrl?: string;
|
|
32
|
+
}>;
|
|
33
|
+
export default handleOAuthCallbackAction;
|
|
@@ -0,0 +1,80 @@
|
|
|
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 server';
|
|
19
|
+
import { cookies } from 'next/headers';
|
|
20
|
+
import { CookieConfig } from '@asgardeo/node';
|
|
21
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
22
|
+
/**
|
|
23
|
+
* Server action to handle OAuth callback with authorization code.
|
|
24
|
+
* This action processes the authorization code received from the OAuth provider
|
|
25
|
+
* and exchanges it for tokens to complete the authentication flow.
|
|
26
|
+
*
|
|
27
|
+
* @param code - Authorization code from OAuth provider
|
|
28
|
+
* @param state - State parameter from OAuth provider for CSRF protection
|
|
29
|
+
* @param sessionState - Session state parameter from OAuth provider
|
|
30
|
+
* @returns Promise that resolves with success status and optional error message
|
|
31
|
+
*/
|
|
32
|
+
const handleOAuthCallbackAction = async (code, state, sessionState) => {
|
|
33
|
+
try {
|
|
34
|
+
if (!code || !state) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: 'Missing required OAuth parameters: code and state are required'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Get the Asgardeo client instance
|
|
41
|
+
const asgardeoClient = AsgardeoNextClient.getInstance();
|
|
42
|
+
if (!asgardeoClient.isInitialized) {
|
|
43
|
+
return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: 'Asgardeo client is not initialized'
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Get the session ID from cookies
|
|
49
|
+
const cookieStore = await cookies();
|
|
50
|
+
const sessionId = cookieStore.get(CookieConfig.SESSION_COOKIE_NAME)?.value;
|
|
51
|
+
if (!sessionId) {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: 'No session found. Please start the authentication flow again.'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Exchange the authorization code for tokens
|
|
58
|
+
await asgardeoClient.signIn({
|
|
59
|
+
code,
|
|
60
|
+
session_state: sessionState,
|
|
61
|
+
state,
|
|
62
|
+
}, {}, sessionId);
|
|
63
|
+
// Get the after sign-in URL from configuration
|
|
64
|
+
const config = await asgardeoClient.getConfiguration();
|
|
65
|
+
const afterSignInUrl = config.afterSignInUrl || '/';
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
redirectUrl: afterSignInUrl
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error('[handleOAuthCallbackAction] OAuth callback error:', error);
|
|
73
|
+
return {
|
|
74
|
+
success: false,
|
|
75
|
+
error: error instanceof Error ? error.message : 'Authentication failed'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
export default handleOAuthCallbackAction;
|
|
80
|
+
//# sourceMappingURL=handleOAuthCallbackAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleOAuthCallbackAction.js","sourceRoot":"","sources":["../../../src/server/actions/handleOAuthCallbackAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;;;GASG;AACH,MAAM,yBAAyB,GAAG,KAAK,EACrC,IAAY,EACZ,KAAa,EACb,YAAqB,EAKpB,EAAE;IACH,IAAI,CAAC;QACH,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,gEAAgE;aACxE,CAAC;QACJ,CAAC;QAED,mCAAmC;QACnC,MAAM,cAAc,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAExD,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;YAClC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,oCAAoC;aAC5C,CAAC;QACJ,CAAC;QAED,kCAAkC;QAClC,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;QACpC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC;QAE3E,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,+DAA+D;aACvE,CAAC;QACJ,CAAC;QAED,6CAA6C;QAC7C,MAAM,cAAc,CAAC,MAAM,CACzB;YACE,IAAI;YACJ,aAAa,EAAE,YAAY;YAC3B,KAAK;SACC,EACR,EAAE,EACF,SAAS,CACV,CAAC;QAEF,+CAA+C;QAC/C,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACvD,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,GAAG,CAAC;QAEpD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,cAAc;SAC5B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mDAAmD,EAAE,KAAK,CAAC,CAAC;QAE1E,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB;SACxE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
'use server';
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
return !!
|
|
19
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
|
+
const isSignedIn = async (sessionId) => {
|
|
21
|
+
const client = AsgardeoNextClient.getInstance();
|
|
22
|
+
const accessToken = await client.getAccessToken(sessionId);
|
|
23
|
+
return !!accessToken;
|
|
24
24
|
};
|
|
25
25
|
export default isSignedIn;
|
|
26
26
|
//# sourceMappingURL=isSignedIn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSignedIn.js","sourceRoot":"","sources":["../../../src/server/actions/isSignedIn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,
|
|
1
|
+
{"version":3,"file":"isSignedIn.js","sourceRoot":"","sources":["../../../src/server/actions/isSignedIn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAG1D,MAAM,UAAU,GAAG,KAAK,EAAE,SAAiB,EAAoB,EAAE;IAC/D,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,WAAW,GAAuB,MAAM,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAE/E,OAAO,CAAC,CAAC,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { EmbeddedSignInFlowHandleRequestPayload, EmbeddedFlowExecuteRequestConfig, EmbeddedSignInFlowInitiateResponse } from '@asgardeo/node';
|
|
19
|
+
/**
|
|
20
|
+
* Server action for signing in a user.
|
|
21
|
+
* Handles the embedded sign-in flow and manages session cookies.
|
|
22
|
+
*
|
|
23
|
+
* @param payload - The embedded sign-in flow payload
|
|
24
|
+
* @param request - The embedded flow execute request config
|
|
25
|
+
* @returns Promise that resolves when sign-in is complete
|
|
26
|
+
*/
|
|
27
|
+
declare const signInAction: (payload?: EmbeddedSignInFlowHandleRequestPayload, request?: EmbeddedFlowExecuteRequestConfig) => Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: {
|
|
30
|
+
afterSignInUrl?: string;
|
|
31
|
+
signInUrl?: string;
|
|
32
|
+
} | EmbeddedSignInFlowInitiateResponse;
|
|
33
|
+
error?: string;
|
|
34
|
+
}>;
|
|
35
|
+
export default signInAction;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 server';
|
|
19
|
+
import { cookies } from 'next/headers';
|
|
20
|
+
import { CookieConfig, generateSessionId, EmbeddedSignInFlowStatus, } from '@asgardeo/node';
|
|
21
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
22
|
+
/**
|
|
23
|
+
* Server action for signing in a user.
|
|
24
|
+
* Handles the embedded sign-in flow and manages session cookies.
|
|
25
|
+
*
|
|
26
|
+
* @param payload - The embedded sign-in flow payload
|
|
27
|
+
* @param request - The embedded flow execute request config
|
|
28
|
+
* @returns Promise that resolves when sign-in is complete
|
|
29
|
+
*/
|
|
30
|
+
const signInAction = async (payload, request) => {
|
|
31
|
+
try {
|
|
32
|
+
const client = AsgardeoNextClient.getInstance();
|
|
33
|
+
const cookieStore = await cookies();
|
|
34
|
+
let userId = cookieStore.get(CookieConfig.SESSION_COOKIE_NAME)?.value;
|
|
35
|
+
if (!userId) {
|
|
36
|
+
userId = generateSessionId();
|
|
37
|
+
cookieStore.set(CookieConfig.SESSION_COOKIE_NAME, userId, {
|
|
38
|
+
httpOnly: CookieConfig.DEFAULT_HTTP_ONLY,
|
|
39
|
+
maxAge: CookieConfig.DEFAULT_MAX_AGE,
|
|
40
|
+
sameSite: CookieConfig.DEFAULT_SAME_SITE,
|
|
41
|
+
secure: CookieConfig.DEFAULT_SECURE,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// If no payload provided, redirect to sign-in URL for redirect-based sign-in.
|
|
45
|
+
// If there's a payload, handle the embedded sign-in flow.
|
|
46
|
+
if (!payload) {
|
|
47
|
+
const defaultSignInUrl = await client.getAuthorizeRequestUrl({}, userId);
|
|
48
|
+
return { success: true, data: { signInUrl: String(defaultSignInUrl) } };
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const response = await client.signIn(payload, request, userId);
|
|
52
|
+
if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) {
|
|
53
|
+
// Complete the sign-in process
|
|
54
|
+
await client.signIn({
|
|
55
|
+
code: response?.authData?.code,
|
|
56
|
+
session_state: response?.authData?.session_state,
|
|
57
|
+
state: response?.authData?.state,
|
|
58
|
+
}, {}, userId);
|
|
59
|
+
const afterSignInUrl = await (await client.getStorageManager()).getConfigDataParameter('afterSignInUrl');
|
|
60
|
+
return { success: true, data: { afterSignInUrl: String(afterSignInUrl) } };
|
|
61
|
+
}
|
|
62
|
+
return { success: true, data: response };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('[signInAction] Error during sign-in:', error);
|
|
67
|
+
return { success: false, error: String(error) };
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export default signInAction;
|
|
71
|
+
//# sourceMappingURL=signInAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signInAction.js","sourceRoot":"","sources":["../../../src/server/actions/signInAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GAIzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,KAAK,EACxB,OAAgD,EAChD,OAA0C,EAUzC,EAAE;IACH,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;QAEpC,IAAI,MAAM,GAAuB,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC;QAE1F,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,iBAAiB,EAAE,CAAC;YAC7B,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,mBAAmB,EAAE,MAAM,EAAE;gBACxD,QAAQ,EAAE,YAAY,CAAC,iBAAiB;gBACxC,MAAM,EAAE,YAAY,CAAC,eAAe;gBACpC,QAAQ,EAAE,YAAY,CAAC,iBAAiB;gBACxC,MAAM,EAAE,YAAY,CAAC,cAAc;aACpC,CAAC,CAAC;QACL,CAAC;QAED,8EAA8E;QAC9E,0DAA0D;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAEzE,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAC,EAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAQ,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAQ,EAAE,MAAM,CAAC,CAAC;YAErE,IAAI,QAAQ,CAAC,UAAU,KAAK,wBAAwB,CAAC,gBAAgB,EAAE,CAAC;gBACtE,+BAA+B;gBAC/B,MAAM,MAAM,CAAC,MAAM,CACjB;oBACE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI;oBAC9B,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa;oBAChD,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;iBAC1B,EACR,EAAE,EACF,MAAM,CACP,CAAC;gBAEF,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;gBAEzG,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,EAAC,EAAC,CAAC;YACzE,CAAC;YAED,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAA8C,EAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
declare const signOutAction: () => Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
data?: {
|
|
21
|
+
afterSignOutUrl?: string;
|
|
22
|
+
};
|
|
23
|
+
error?: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
export default signOutAction;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 server';
|
|
19
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
|
+
import deleteSessionId from './deleteSessionId';
|
|
21
|
+
const signOutAction = async () => {
|
|
22
|
+
try {
|
|
23
|
+
const client = AsgardeoNextClient.getInstance();
|
|
24
|
+
const afterSignOutUrl = await client.signOut();
|
|
25
|
+
await deleteSessionId();
|
|
26
|
+
return { success: true, data: { afterSignOutUrl } };
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return { success: false, error };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export default signOutAction;
|
|
33
|
+
//# sourceMappingURL=signOutAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signOutAction.js","sourceRoot":"","sources":["../../../src/server/actions/signOutAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,aAAa,GAAG,KAAK,IAAqF,EAAE;IAChH,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,eAAe,GAAW,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QAEvD,MAAM,eAAe,EAAE,CAAC;QAExB,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,eAAe,EAAC,EAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC;IACjC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { EmbeddedFlowExecuteRequestConfig, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from '@asgardeo/node';
|
|
19
|
+
/**
|
|
20
|
+
* Server action for signing in a user.
|
|
21
|
+
* Handles the embedded sign-in flow and manages session cookies.
|
|
22
|
+
*
|
|
23
|
+
* @param payload - The embedded sign-in flow payload
|
|
24
|
+
* @param request - The embedded flow execute request config
|
|
25
|
+
* @returns Promise that resolves when sign-in is complete
|
|
26
|
+
*/
|
|
27
|
+
declare const signUpAction: (payload?: EmbeddedFlowExecuteRequestPayload, request?: EmbeddedFlowExecuteRequestConfig) => Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: {
|
|
30
|
+
afterSignUpUrl?: string;
|
|
31
|
+
signUpUrl?: string;
|
|
32
|
+
} | EmbeddedFlowExecuteResponse;
|
|
33
|
+
error?: string;
|
|
34
|
+
}>;
|
|
35
|
+
export default signUpAction;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 server';
|
|
19
|
+
import { EmbeddedFlowStatus, } from '@asgardeo/node';
|
|
20
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
21
|
+
/**
|
|
22
|
+
* Server action for signing in a user.
|
|
23
|
+
* Handles the embedded sign-in flow and manages session cookies.
|
|
24
|
+
*
|
|
25
|
+
* @param payload - The embedded sign-in flow payload
|
|
26
|
+
* @param request - The embedded flow execute request config
|
|
27
|
+
* @returns Promise that resolves when sign-in is complete
|
|
28
|
+
*/
|
|
29
|
+
const signUpAction = async (payload, request) => {
|
|
30
|
+
try {
|
|
31
|
+
const client = AsgardeoNextClient.getInstance();
|
|
32
|
+
// If no payload provided, redirect to sign-in URL for redirect-based sign-in.
|
|
33
|
+
// If there's a payload, handle the embedded sign-in flow.
|
|
34
|
+
if (!payload) {
|
|
35
|
+
const defaultSignUpUrl = '';
|
|
36
|
+
return { success: true, data: { signUpUrl: String(defaultSignUpUrl) } };
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const response = await client.signUp(payload);
|
|
40
|
+
if (response.flowStatus === EmbeddedFlowStatus.Complete) {
|
|
41
|
+
const afterSignUpUrl = await (await client.getStorageManager()).getConfigDataParameter('afterSignInUrl');
|
|
42
|
+
return { success: true, data: { afterSignUpUrl: String(afterSignUpUrl) } };
|
|
43
|
+
}
|
|
44
|
+
return { success: true, data: response };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return { success: false, error: String(error) };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export default signUpAction;
|
|
52
|
+
//# sourceMappingURL=signUpAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signUpAction.js","sourceRoot":"","sources":["../../../src/server/actions/signUpAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAEb,OAAO,EAIL,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,KAAK,EACxB,OAA2C,EAC3C,OAA0C,EAUzC,EAAE;IACH,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAEhD,8EAA8E;QAC9E,0DAA0D;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,gBAAgB,GAAG,EAAE,CAAC;YAE5B,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAC,EAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAQ,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAEnD,IAAI,QAAQ,CAAC,UAAU,KAAK,kBAAkB,CAAC,QAAQ,EAAE,CAAC;gBACxD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;gBAEzG,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,EAAC,EAAC,CAAC;YACzE,CAAC;YAED,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAuC,EAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { User } from '@asgardeo/node';
|
|
19
|
+
/**
|
|
20
|
+
* Server action to get the current user.
|
|
21
|
+
* Returns the user profile if signed in.
|
|
22
|
+
*/
|
|
23
|
+
declare const updateUserProfileAction: (payload: any, sessionId: string) => Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
data: {
|
|
26
|
+
user: User;
|
|
27
|
+
};
|
|
28
|
+
error: null;
|
|
29
|
+
} | {
|
|
30
|
+
success: boolean;
|
|
31
|
+
data: {
|
|
32
|
+
user: {};
|
|
33
|
+
};
|
|
34
|
+
error: string;
|
|
35
|
+
}>;
|
|
36
|
+
export default updateUserProfileAction;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 server';
|
|
19
|
+
import AsgardeoNextClient from '../../AsgardeoNextClient';
|
|
20
|
+
/**
|
|
21
|
+
* Server action to get the current user.
|
|
22
|
+
* Returns the user profile if signed in.
|
|
23
|
+
*/
|
|
24
|
+
const updateUserProfileAction = async (payload, sessionId) => {
|
|
25
|
+
try {
|
|
26
|
+
const client = AsgardeoNextClient.getInstance();
|
|
27
|
+
const user = await client.updateUserProfile(payload, sessionId);
|
|
28
|
+
return { success: true, data: { user }, error: null };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
data: {
|
|
34
|
+
user: {},
|
|
35
|
+
},
|
|
36
|
+
error: 'Failed to get user profile',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export default updateUserProfileAction;
|
|
41
|
+
//# sourceMappingURL=updateUserProfileAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateUserProfileAction.js","sourceRoot":"","sources":["../../../src/server/actions/updateUserProfileAction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,CAAC;AAGb,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAAY,EAAE,SAAiB,EAAE,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,IAAI,GAAS,MAAM,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,EAAE;aACT;YACD,KAAK,EAAE,4BAA4B;SACpC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
const decorateConfigWithNextEnv = (config) => {
|
|
19
|
-
const { baseUrl, clientId, clientSecret, ...rest } = config;
|
|
19
|
+
const { baseUrl, clientId, clientSecret, signInUrl, signUpUrl, afterSignInUrl, afterSignOutUrl, ...rest } = config;
|
|
20
20
|
return {
|
|
21
21
|
...rest,
|
|
22
22
|
baseUrl: baseUrl || process.env['NEXT_PUBLIC_ASGARDEO_BASE_URL'],
|
|
23
23
|
clientId: clientId || process.env['NEXT_PUBLIC_ASGARDEO_CLIENT_ID'],
|
|
24
24
|
clientSecret: clientSecret || process.env['ASGARDEO_CLIENT_SECRET'],
|
|
25
|
+
afterSignInUrl: afterSignInUrl || process.env['NEXT_PUBLIC_ASGARDEO_AFTER_SIGN_IN_URL'],
|
|
26
|
+
signInUrl: signInUrl || process.env['NEXT_PUBLIC_ASGARDEO_SIGN_IN_URL'],
|
|
27
|
+
afterSignOutUrl: afterSignOutUrl || process.env['NEXT_PUBLIC_ASGARDEO_AFTER_SIGN_OUT_URL'],
|
|
28
|
+
signUpUrl: signUpUrl || process.env['NEXT_PUBLIC_ASGARDEO_SIGN_UP_URL'],
|
|
25
29
|
};
|
|
26
30
|
};
|
|
27
31
|
export default decorateConfigWithNextEnv;
|