@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
package/README.md
CHANGED
|
@@ -23,6 +23,8 @@ yarn add @asgardeo/nextjs
|
|
|
23
23
|
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
|
+
### Option 1: Provider-based Configuration (Recommended)
|
|
27
|
+
|
|
26
28
|
1. Create a `.env.local` file with your Asgardeo configuration:
|
|
27
29
|
|
|
28
30
|
```bash
|
|
@@ -31,24 +33,64 @@ NEXT_PUBLIC_ASGARDEO_CLIENT_ID=<your-client-id>
|
|
|
31
33
|
NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET=<your-client-secret>
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
2.
|
|
36
|
+
2. Add the `AsgardeoProvider` to your root layout with configuration:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// app/layout.tsx
|
|
40
|
+
import { AsgardeoProvider } from '@asgardeo/nextjs';
|
|
41
|
+
|
|
42
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
43
|
+
const asgardeoConfig = {
|
|
44
|
+
baseUrl: process.env.NEXT_PUBLIC_ASGARDEO_BASE_URL,
|
|
45
|
+
clientId: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_ID,
|
|
46
|
+
clientSecret: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET,
|
|
47
|
+
afterSignInUrl: process.env.NEXT_PUBLIC_ASGARDEO_AFTER_SIGN_IN_URL || 'http://localhost:3000',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<html lang="en">
|
|
52
|
+
<body>
|
|
53
|
+
<AsgardeoProvider config={asgardeoConfig}>
|
|
54
|
+
{children}
|
|
55
|
+
</AsgardeoProvider>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. Create a simple `middleware.ts` file in your project root:
|
|
35
63
|
|
|
36
64
|
```typescript
|
|
37
|
-
import {
|
|
38
|
-
|
|
65
|
+
import { asgardeoMiddleware } from '@asgardeo/nextjs/middleware';
|
|
66
|
+
|
|
67
|
+
export default asgardeoMiddleware;
|
|
68
|
+
|
|
69
|
+
export const config = {
|
|
70
|
+
matcher: [
|
|
71
|
+
// Skip Next.js internals and all static files, unless found in search params
|
|
72
|
+
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
|
|
73
|
+
// Always run for API routes
|
|
74
|
+
'/(api|trpc)(.*)',
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
```
|
|
39
78
|
|
|
40
|
-
|
|
79
|
+
### Option 2: Middleware-based Configuration
|
|
80
|
+
|
|
81
|
+
2. Then create a `middleware.ts` file in your project root to handle authentication:
|
|
41
82
|
|
|
42
|
-
|
|
83
|
+
```typescript
|
|
84
|
+
import { createAsgardeoMiddleware } from '@asgardeo/nextjs/middleware';
|
|
85
|
+
|
|
86
|
+
const middleware = createAsgardeoMiddleware({
|
|
43
87
|
baseUrl: process.env.NEXT_PUBLIC_ASGARDEO_BASE_URL,
|
|
44
88
|
clientId: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_ID,
|
|
45
89
|
clientSecret: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET,
|
|
46
90
|
afterSignInUrl: 'http://localhost:3000',
|
|
47
91
|
});
|
|
48
92
|
|
|
49
|
-
export
|
|
50
|
-
return await asgardeo.middleware(request);
|
|
51
|
-
}
|
|
93
|
+
export { middleware };
|
|
52
94
|
|
|
53
95
|
export const config = {
|
|
54
96
|
matcher: [
|
|
@@ -82,6 +124,24 @@ export default function Home() {
|
|
|
82
124
|
}
|
|
83
125
|
```
|
|
84
126
|
|
|
127
|
+
## Server-side Usage
|
|
128
|
+
|
|
129
|
+
You can access the Asgardeo client instance in server actions and other server-side code:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { getAsgardeoClient } from '@asgardeo/nextjs/server';
|
|
133
|
+
|
|
134
|
+
export async function getUserProfile() {
|
|
135
|
+
const client = getAsgardeoClient();
|
|
136
|
+
const user = await client.getUser();
|
|
137
|
+
return user;
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Architecture
|
|
142
|
+
|
|
143
|
+
The SDK uses a singleton pattern for the `AsgardeoNextClient` to ensure consistent authentication state across your application. The client is automatically initialized when you provide configuration through the `AsgardeoProvider` or through the middleware configuration.
|
|
144
|
+
|
|
85
145
|
## License
|
|
86
146
|
|
|
87
147
|
Apache-2.0
|
|
@@ -15,27 +15,62 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoNodeClient, SignInOptions, SignOutOptions, User, UserProfile } from '@asgardeo/node';
|
|
19
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
18
|
+
import { AsgardeoNodeClient, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse, SignInOptions, SignOutOptions, SignUpOptions, User, UserProfile, Organization, EmbeddedSignInFlowHandleRequestPayload, EmbeddedFlowExecuteRequestConfig, ExtendedAuthorizeRequestUrlParams } from '@asgardeo/node';
|
|
20
19
|
import { AsgardeoNextConfig } from './models/config';
|
|
21
20
|
/**
|
|
22
21
|
* Client for mplementing Asgardeo in Next.js applications.
|
|
23
22
|
* This class provides the core functionality for managing user authentication and sessions.
|
|
24
23
|
*
|
|
24
|
+
* This class is implemented as a singleton to ensure a single instance across the application.
|
|
25
|
+
*
|
|
25
26
|
* @typeParam T - Configuration type that extends AsgardeoNextConfig.
|
|
26
27
|
*/
|
|
27
28
|
declare class AsgardeoNextClient<T extends AsgardeoNextConfig = AsgardeoNextConfig> extends AsgardeoNodeClient<T> {
|
|
29
|
+
private static instance;
|
|
28
30
|
private asgardeo;
|
|
29
|
-
|
|
31
|
+
isInitialized: boolean;
|
|
32
|
+
private constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Get the singleton instance of AsgardeoNextClient
|
|
35
|
+
*/
|
|
36
|
+
static getInstance<T extends AsgardeoNextConfig = AsgardeoNextConfig>(): AsgardeoNextClient<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Ensures the client is initialized before using it.
|
|
39
|
+
* Throws an error if the client is not initialized.
|
|
40
|
+
*/
|
|
41
|
+
private ensureInitialized;
|
|
30
42
|
initialize(config: T): Promise<boolean>;
|
|
31
43
|
getUser(userId?: string): Promise<User>;
|
|
32
|
-
getUserProfile(): Promise<UserProfile>;
|
|
44
|
+
getUserProfile(userId?: string): Promise<UserProfile>;
|
|
45
|
+
updateUserProfile(payload: any, userId?: string): Promise<User>;
|
|
46
|
+
getOrganizations(): Promise<Organization[]>;
|
|
47
|
+
switchOrganization(organization: Organization): Promise<void>;
|
|
48
|
+
getCurrentOrganization(): Promise<Organization | null>;
|
|
33
49
|
isLoading(): boolean;
|
|
34
50
|
isSignedIn(sessionId?: string): Promise<boolean>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
getAccessToken(sessionId?: string): Promise<string>;
|
|
52
|
+
getConfiguration(): T;
|
|
53
|
+
signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
54
|
+
signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
55
|
+
signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
|
|
56
|
+
signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
|
|
57
|
+
signUp(options?: SignUpOptions): Promise<void>;
|
|
58
|
+
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the sign-in URL for authentication.
|
|
61
|
+
* Ensures the client is initialized before making the call.
|
|
62
|
+
*
|
|
63
|
+
* @param customParams - Custom parameters to include in the sign-in URL.
|
|
64
|
+
* @param userId - The user ID
|
|
65
|
+
* @returns Promise that resolves to the sign-in URL
|
|
66
|
+
*/
|
|
67
|
+
getAuthorizeRequestUrl(customParams: ExtendedAuthorizeRequestUrlParams, userId?: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the storage manager from the underlying Asgardeo client.
|
|
70
|
+
* Ensures the client is initialized before making the call.
|
|
71
|
+
*
|
|
72
|
+
* @returns Promise that resolves to the storage manager
|
|
73
|
+
*/
|
|
74
|
+
getStorageManager(): Promise<any>;
|
|
40
75
|
}
|
|
41
76
|
export default AsgardeoNextClient;
|
|
@@ -15,42 +15,146 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { AsgardeoNodeClient, LegacyAsgardeoNodeClient, } from '@asgardeo/node';
|
|
19
|
-
import { NextResponse } from 'next/server';
|
|
20
|
-
import deleteSessionId from './server/actions/deleteSessionId';
|
|
18
|
+
import { AsgardeoNodeClient, AsgardeoRuntimeError, LegacyAsgardeoNodeClient, initializeEmbeddedSignInFlow, executeEmbeddedSignInFlow, generateUserProfile, flattenUserSchema, getScim2Me, getSchemas, generateFlattenedUserProfile, updateMeProfile, executeEmbeddedSignUpFlow, } from '@asgardeo/node';
|
|
21
19
|
import getSessionId from './server/actions/getSessionId';
|
|
22
|
-
import getIsSignedIn from './server/actions/isSignedIn';
|
|
23
|
-
import setSessionId from './server/actions/setSessionId';
|
|
24
20
|
import decorateConfigWithNextEnv from './utils/decorateConfigWithNextEnv';
|
|
25
|
-
import
|
|
21
|
+
import getClientOrigin from './server/actions/getClientOrigin';
|
|
26
22
|
const removeTrailingSlash = (path) => (path.endsWith('/') ? path.slice(0, -1) : path);
|
|
27
23
|
/**
|
|
28
24
|
* Client for mplementing Asgardeo in Next.js applications.
|
|
29
25
|
* This class provides the core functionality for managing user authentication and sessions.
|
|
30
26
|
*
|
|
27
|
+
* This class is implemented as a singleton to ensure a single instance across the application.
|
|
28
|
+
*
|
|
31
29
|
* @typeParam T - Configuration type that extends AsgardeoNextConfig.
|
|
32
30
|
*/
|
|
33
31
|
class AsgardeoNextClient extends AsgardeoNodeClient {
|
|
32
|
+
static instance;
|
|
34
33
|
asgardeo;
|
|
34
|
+
isInitialized = false;
|
|
35
35
|
constructor() {
|
|
36
36
|
super();
|
|
37
37
|
this.asgardeo = new LegacyAsgardeoNodeClient();
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Get the singleton instance of AsgardeoNextClient
|
|
41
|
+
*/
|
|
42
|
+
static getInstance() {
|
|
43
|
+
if (!AsgardeoNextClient.instance) {
|
|
44
|
+
AsgardeoNextClient.instance = new AsgardeoNextClient();
|
|
45
|
+
}
|
|
46
|
+
return AsgardeoNextClient.instance;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Ensures the client is initialized before using it.
|
|
50
|
+
* Throws an error if the client is not initialized.
|
|
51
|
+
*/
|
|
52
|
+
async ensureInitialized() {
|
|
53
|
+
if (!this.isInitialized) {
|
|
54
|
+
throw new Error('[AsgardeoNextClient] Client is not initialized. Make sure you have wrapped your app with AsgardeoProvider and provided the required configuration (baseUrl, clientId, etc.).');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async initialize(config) {
|
|
58
|
+
if (this.isInitialized) {
|
|
59
|
+
console.warn('[AsgardeoNextClient] Client is already initialized');
|
|
60
|
+
return Promise.resolve(true);
|
|
61
|
+
}
|
|
62
|
+
const { baseUrl, clientId, clientSecret, signInUrl, afterSignInUrl, afterSignOutUrl, signUpUrl, ...rest } = decorateConfigWithNextEnv(config);
|
|
63
|
+
this.isInitialized = true;
|
|
64
|
+
const origin = await getClientOrigin();
|
|
41
65
|
return this.asgardeo.initialize({
|
|
42
66
|
baseUrl,
|
|
43
|
-
clientId
|
|
67
|
+
clientId,
|
|
44
68
|
clientSecret,
|
|
45
|
-
|
|
69
|
+
signInUrl,
|
|
70
|
+
signUpUrl,
|
|
71
|
+
afterSignInUrl: afterSignInUrl ?? origin,
|
|
72
|
+
afterSignOutUrl: afterSignOutUrl ?? origin,
|
|
73
|
+
enablePKCE: false,
|
|
46
74
|
...rest,
|
|
47
75
|
});
|
|
48
76
|
}
|
|
49
77
|
async getUser(userId) {
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
await this.ensureInitialized();
|
|
79
|
+
const resolvedSessionId = userId || (await getSessionId());
|
|
80
|
+
try {
|
|
81
|
+
const configData = await this.asgardeo.getConfigData();
|
|
82
|
+
const baseUrl = configData?.baseUrl;
|
|
83
|
+
const profile = await getScim2Me({
|
|
84
|
+
baseUrl,
|
|
85
|
+
headers: {
|
|
86
|
+
Authorization: `Bearer ${await this.getAccessToken(userId)}`,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
const schemas = await getSchemas({
|
|
90
|
+
baseUrl,
|
|
91
|
+
headers: {
|
|
92
|
+
Authorization: `Bearer ${await this.getAccessToken(userId)}`,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
return generateUserProfile(profile, flattenUserSchema(schemas));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return this.asgardeo.getUser(resolvedSessionId);
|
|
99
|
+
}
|
|
52
100
|
}
|
|
53
|
-
getUserProfile() {
|
|
101
|
+
async getUserProfile(userId) {
|
|
102
|
+
await this.ensureInitialized();
|
|
103
|
+
try {
|
|
104
|
+
const configData = await this.asgardeo.getConfigData();
|
|
105
|
+
const baseUrl = configData?.baseUrl;
|
|
106
|
+
const profile = await getScim2Me({
|
|
107
|
+
baseUrl,
|
|
108
|
+
headers: {
|
|
109
|
+
Authorization: `Bearer ${await this.getAccessToken(userId)}`,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
const schemas = await getSchemas({
|
|
113
|
+
baseUrl,
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: `Bearer ${await this.getAccessToken(userId)}`,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
const processedSchemas = flattenUserSchema(schemas);
|
|
119
|
+
const output = {
|
|
120
|
+
schemas: processedSchemas,
|
|
121
|
+
flattenedProfile: generateFlattenedUserProfile(profile, processedSchemas),
|
|
122
|
+
profile,
|
|
123
|
+
};
|
|
124
|
+
return output;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
schemas: [],
|
|
129
|
+
flattenedProfile: await this.asgardeo.getDecodedIdToken(),
|
|
130
|
+
profile: await this.asgardeo.getDecodedIdToken(),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async updateUserProfile(payload, userId) {
|
|
135
|
+
await this.ensureInitialized();
|
|
136
|
+
try {
|
|
137
|
+
const configData = await this.asgardeo.getConfigData();
|
|
138
|
+
const baseUrl = configData?.baseUrl;
|
|
139
|
+
return await updateMeProfile({
|
|
140
|
+
baseUrl,
|
|
141
|
+
payload,
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: `Bearer ${await this.getAccessToken(userId)}`,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new AsgardeoRuntimeError(`Failed to update user profile: ${error instanceof Error ? error.message : 'Unknown error'}`, 'AsgardeoNextClient-UpdateProfileError-001', 'react', 'An error occurred while updating the user profile. Please check your configuration and network connection.');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async getOrganizations() {
|
|
152
|
+
throw new Error('Method not implemented.');
|
|
153
|
+
}
|
|
154
|
+
switchOrganization(organization) {
|
|
155
|
+
throw new Error('Method not implemented.');
|
|
156
|
+
}
|
|
157
|
+
getCurrentOrganization() {
|
|
54
158
|
throw new Error('Method not implemented.');
|
|
55
159
|
}
|
|
56
160
|
isLoading() {
|
|
@@ -59,12 +163,34 @@ class AsgardeoNextClient extends AsgardeoNodeClient {
|
|
|
59
163
|
isSignedIn(sessionId) {
|
|
60
164
|
return this.asgardeo.isSignedIn(sessionId);
|
|
61
165
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
166
|
+
getAccessToken(sessionId) {
|
|
167
|
+
return this.asgardeo.getAccessToken(sessionId);
|
|
168
|
+
}
|
|
169
|
+
getConfiguration() {
|
|
170
|
+
return this.asgardeo.getConfigData();
|
|
171
|
+
}
|
|
172
|
+
async signIn(...args) {
|
|
173
|
+
const arg1 = args[0];
|
|
174
|
+
const arg2 = args[1];
|
|
175
|
+
const arg3 = args[2];
|
|
176
|
+
const arg4 = args[3];
|
|
177
|
+
if (typeof arg1 === 'object' && 'flowId' in arg1) {
|
|
178
|
+
if (arg1.flowId === '') {
|
|
179
|
+
const defaultSignInUrl = new URL(await this.getAuthorizeRequestUrl({
|
|
180
|
+
response_mode: 'direct',
|
|
181
|
+
client_secret: '{{clientSecret}}',
|
|
182
|
+
}));
|
|
183
|
+
return initializeEmbeddedSignInFlow({
|
|
184
|
+
url: `${defaultSignInUrl.origin}${defaultSignInUrl.pathname}`,
|
|
185
|
+
payload: Object.fromEntries(defaultSignInUrl.searchParams.entries()),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return executeEmbeddedSignInFlow({
|
|
189
|
+
payload: arg1,
|
|
190
|
+
url: arg2.url,
|
|
191
|
+
});
|
|
66
192
|
}
|
|
67
|
-
return this.asgardeo.signIn(
|
|
193
|
+
return this.asgardeo.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1);
|
|
68
194
|
}
|
|
69
195
|
async signOut(...args) {
|
|
70
196
|
if (args[1] && typeof args[1] !== 'string') {
|
|
@@ -73,75 +199,42 @@ class AsgardeoNextClient extends AsgardeoNodeClient {
|
|
|
73
199
|
const resolvedSessionId = args[1] || (await getSessionId());
|
|
74
200
|
return Promise.resolve(await this.asgardeo.signOut(resolvedSessionId));
|
|
75
201
|
}
|
|
76
|
-
async
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const { method } = req;
|
|
80
|
-
if ((method === 'GET' && sanitizedPathname === InternalAuthAPIRoutesConfig.signIn) || searchParams.get('code')) {
|
|
81
|
-
let response;
|
|
82
|
-
await this.signIn({}, undefined, (redirectUrl) => {
|
|
83
|
-
return (response = NextResponse.redirect(redirectUrl, 302));
|
|
84
|
-
}, searchParams.get('code'), searchParams.get('session_state'), searchParams.get('state'));
|
|
85
|
-
// If we already redirected via the callback, return that
|
|
86
|
-
if (response) {
|
|
87
|
-
return response;
|
|
88
|
-
}
|
|
89
|
-
if (searchParams.get('code')) {
|
|
90
|
-
const cleanUrl = new URL(req.url);
|
|
91
|
-
cleanUrl.searchParams.delete('code');
|
|
92
|
-
cleanUrl.searchParams.delete('state');
|
|
93
|
-
cleanUrl.searchParams.delete('session_state');
|
|
94
|
-
return NextResponse.redirect(cleanUrl.toString());
|
|
95
|
-
}
|
|
96
|
-
return NextResponse.next();
|
|
97
|
-
}
|
|
98
|
-
if (method === 'GET' && sanitizedPathname === InternalAuthAPIRoutesConfig.session) {
|
|
99
|
-
try {
|
|
100
|
-
const isSignedIn = await getIsSignedIn();
|
|
101
|
-
return NextResponse.json({ isSignedIn: isSignedIn });
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return NextResponse.json({ error: 'Failed to check session' }, { status: 500 });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (method === 'GET' && sanitizedPathname === InternalAuthAPIRoutesConfig.user) {
|
|
108
|
-
try {
|
|
109
|
-
const user = await this.getUser();
|
|
110
|
-
console.log('[AsgardeoNextClient] User fetched successfully:', user);
|
|
111
|
-
return NextResponse.json({ user });
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
console.error('[AsgardeoNextClient] Failed to get user:', error);
|
|
115
|
-
return NextResponse.json({ error: 'Failed to get user' }, { status: 500 });
|
|
116
|
-
}
|
|
202
|
+
async signUp(...args) {
|
|
203
|
+
if (args.length === 0) {
|
|
204
|
+
throw new AsgardeoRuntimeError('No arguments provided for signUp method.', 'AsgardeoNextClient-ValidationError-001', 'nextjs', 'The signUp method requires at least one argument, either a SignUpOptions object or an EmbeddedFlowExecuteRequestPayload.');
|
|
117
205
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return NextResponse.json({ error: 'Failed to sign out' }, { status: 500 });
|
|
127
|
-
}
|
|
206
|
+
const firstArg = args[0];
|
|
207
|
+
if (typeof firstArg === 'object' && 'flowType' in firstArg) {
|
|
208
|
+
const configData = await this.asgardeo.getConfigData();
|
|
209
|
+
const baseUrl = configData?.baseUrl;
|
|
210
|
+
return executeEmbeddedSignUpFlow({
|
|
211
|
+
baseUrl,
|
|
212
|
+
payload: firstArg,
|
|
213
|
+
});
|
|
128
214
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
215
|
+
throw new AsgardeoRuntimeError('Not implemented', 'AsgardeoNextClient-ValidationError-002', 'nextjs', 'The signUp method with SignUpOptions is not implemented in the Next.js client.');
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Gets the sign-in URL for authentication.
|
|
219
|
+
* Ensures the client is initialized before making the call.
|
|
220
|
+
*
|
|
221
|
+
* @param customParams - Custom parameters to include in the sign-in URL.
|
|
222
|
+
* @param userId - The user ID
|
|
223
|
+
* @returns Promise that resolves to the sign-in URL
|
|
224
|
+
*/
|
|
225
|
+
async getAuthorizeRequestUrl(customParams, userId) {
|
|
226
|
+
await this.ensureInitialized();
|
|
227
|
+
return this.asgardeo.getSignInUrl(customParams, userId);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Gets the storage manager from the underlying Asgardeo client.
|
|
231
|
+
* Ensures the client is initialized before making the call.
|
|
232
|
+
*
|
|
233
|
+
* @returns Promise that resolves to the storage manager
|
|
234
|
+
*/
|
|
235
|
+
async getStorageManager() {
|
|
236
|
+
await this.ensureInitialized();
|
|
237
|
+
return this.asgardeo.getStorageManager();
|
|
145
238
|
}
|
|
146
239
|
}
|
|
147
240
|
export default AsgardeoNextClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsgardeoNextClient.js","sourceRoot":"","sources":["../src/AsgardeoNextClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"AsgardeoNextClient.js","sourceRoot":"","sources":["../src/AsgardeoNextClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EAGpB,wBAAwB,EAMxB,4BAA4B,EAG5B,yBAAyB,EAGzB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,4BAA4B,EAC5B,eAAe,EACf,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AA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
31
|
__export(index_exports, {
|
|
32
32
|
AsgardeoNext: () => import_AsgardeoNextClient.default,
|
|
33
33
|
AsgardeoProvider: () => import_AsgardeoProvider.default,
|
|
34
|
+
SignIn: () => import_SignIn.default,
|
|
34
35
|
SignInButton: () => import_SignInButton.default,
|
|
35
36
|
SignOutButton: () => import_SignOutButton.default,
|
|
37
|
+
SignUp: () => import_SignUp.default,
|
|
38
|
+
SignUpButton: () => import_SignUpButton.default,
|
|
36
39
|
SignedIn: () => import_SignedIn.default,
|
|
37
40
|
SignedInProps: () => import_SignedIn2.SignedInProps,
|
|
38
41
|
SignedOut: () => import_SignedOut.default,
|
|
39
42
|
SignedOutProps: () => import_SignedOut2.SignedOutProps,
|
|
40
43
|
User: () => import_User.default,
|
|
41
|
-
|
|
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
|
|
42
50
|
});
|
|
43
51
|
module.exports = __toCommonJS(index_exports);
|
|
44
52
|
var import_AsgardeoProvider = __toESM(require("./server/AsgardeoProvider"), 1);
|
|
45
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);
|
|
46
56
|
var import_isSignedIn = __toESM(require("./server/actions/isSignedIn"), 1);
|
|
57
|
+
var import_handleOAuthCallbackAction = __toESM(require("./server/actions/handleOAuthCallbackAction"), 1);
|
|
47
58
|
var import_SignedIn = __toESM(require("./client/components/control/SignedIn/SignedIn"), 1);
|
|
48
59
|
var import_SignedIn2 = require("./client/components/control/SignedIn/SignedIn");
|
|
49
60
|
var import_SignedOut = __toESM(require("./client/components/control/SignedOut/SignedOut"), 1);
|
|
50
61
|
var import_SignedOut2 = require("./client/components/control/SignedOut/SignedOut");
|
|
51
62
|
var import_SignInButton = __toESM(require("./client/components/actions/SignInButton/SignInButton"), 1);
|
|
63
|
+
var import_SignUpButton = __toESM(require("./client/components/actions/SignUpButton/SignUpButton"), 1);
|
|
64
|
+
var import_SignIn = __toESM(require("./client/components/presentation/SignIn/SignIn"), 1);
|
|
52
65
|
var import_SignOutButton = __toESM(require("./client/components/actions/SignOutButton/SignOutButton"), 1);
|
|
53
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);
|
|
54
70
|
var import_AsgardeoNextClient = __toESM(require("./AsgardeoNextClient"), 1);
|
|
71
|
+
var import_asgardeoMiddleware = __toESM(require("./middleware/asgardeoMiddleware"), 1);
|
|
55
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
73
|
0 && (module.exports = {
|
|
57
74
|
AsgardeoNext,
|
|
58
75
|
AsgardeoProvider,
|
|
76
|
+
SignIn,
|
|
59
77
|
SignInButton,
|
|
60
78
|
SignOutButton,
|
|
79
|
+
SignUp,
|
|
80
|
+
SignUpButton,
|
|
61
81
|
SignedIn,
|
|
62
82
|
SignedInProps,
|
|
63
83
|
SignedOut,
|
|
64
84
|
SignedOutProps,
|
|
65
85
|
User,
|
|
86
|
+
UserDropdown,
|
|
87
|
+
UserProfile,
|
|
88
|
+
asgardeoMiddleware,
|
|
89
|
+
handleOAuthCallback,
|
|
66
90
|
isSignedIn,
|
|
67
|
-
|
|
91
|
+
useAsgardeo,
|
|
92
|
+
...require("./server/AsgardeoProvider"),
|
|
93
|
+
...require("./client/contexts/Asgardeo/useAsgardeo")
|
|
68
94
|
});
|
|
69
95
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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 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;AAkBA,8BAA0C;AAC1C,0BAAc,sCAnBd;AAqBA,wBAAoC;AAEpC,sBAAkC;AAClC,IAAAA,mBAA4B;AAE5B,uBAAmC;AACnC,IAAAC,oBAA6B;AAE7B,0BAAsC;AAGtC,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
|
|
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
|
|
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
|
*/
|