Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ authClient.signOut();

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
48 changes: 1 addition & 47 deletions packages/express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,6 @@ pnpm add @asgardeo/express
yarn add @asgardeo/express
```

## Quick Start

```javascript
import { AsgardeoExpressClient } from "@asgardeo/express";

// Initialize the client
const authClient = new AsgardeoExpressClient({
clientId: "<your_client_id>",
clientSecret: "<your_client_secret>",
baseUrl: "https://api.asgardeo.io/t/<org_name>",
callbackURL: "http://localhost:3000/callback"
});

// Example Express.js integration
import express from "express";
const app = express();

// Login endpoint
app.get("/login", (req, res) => {
const authUrl = authClient.getSignInUrl();
res.redirect(authUrl);
});

// Callback handler
app.get("/callback", async (req, res) => {
try {
const { code } = req.query;
const tokens = await authClient.exchangeAuthorizationCode(code);
// Store tokens and redirect to home page
res.redirect("/");
} catch (error) {
res.status(500).send("Authentication failed");
}
});

// Get user info
app.get("/userinfo", async (req, res) => {
try {
const userInfo = await authClient.getUserInfo();
res.json(userInfo);
} catch (error) {
res.status(401).send("Unauthorized");
}
});
```

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
49 changes: 5 additions & 44 deletions packages/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,11 @@
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
</div>

## Installation

```bash
# Using npm
npm install @asgardeo/javascript

# or using pnpm
pnpm add @asgardeo/javascript

# or using yarn
yarn add @asgardeo/javascript
```

## Quick Start

```javascript
import { AsgardeoAuth } from "@asgardeo/javascript";

// Initialize the auth instance
const auth = new AsgardeoAuth({
afterSignInUrl: "https://localhost:3000",
clientId: "<your_client_id>",
baseUrl: "https://api.asgardeo.io/t/<org_name>"
});

// Handle authentication
auth.signIn()
.then(() => {
// Handle successful sign in
})
.catch((error) => {
// Handle sign in error
});

// Get authenticated user
auth.getUser()
.then((userInfo) => {
console.log(userInfo);
});

// Sign out
auth.signOut();
```
> [!IMPORTANT]
> ⚠️ Do not directly use this in your applications.
> `@asgardeo/javascript` is a framework agnostic SDK that provides core authentication functionalities.
> For framework-specific integrations, consider using the dedicated SDKs such as `@asgardeo/react`, `@asgardeo/next`, etc.

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
134 changes: 4 additions & 130 deletions packages/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,140 +8,14 @@
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
</div>

## Installation

```bash
# Using npm
npm install @asgardeo/nextjs

# or using pnpm
pnpm add @asgardeo/nextjs

# or using yarn
yarn add @asgardeo/nextjs
```

## Quick Start

### Option 1: Provider-based Configuration (Recommended)

1. Create a `.env.local` file with your Asgardeo configuration:

```bash
NEXT_PUBLIC_ASGARDEO_BASE_URL=https://api.asgardeo.io/t/<your-organization-name>
NEXT_PUBLIC_ASGARDEO_CLIENT_ID=<your-client-id>
NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET=<your-client-secret>
```

2. Add the `AsgardeoProvider` to your root layout with configuration:

```tsx
// app/layout.tsx
import { AsgardeoProvider } from '@asgardeo/nextjs';

export default function RootLayout({ children }: { children: React.ReactNode }) {
const asgardeoConfig = {
baseUrl: process.env.NEXT_PUBLIC_ASGARDEO_BASE_URL,
clientId: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_ID,
clientSecret: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET,
afterSignInUrl: process.env.NEXT_PUBLIC_ASGARDEO_AFTER_SIGN_IN_URL || 'http://localhost:3000',
};

return (
<html lang="en">
<body>
<AsgardeoProvider config={asgardeoConfig}>
{children}
</AsgardeoProvider>
</body>
</html>
);
}
```

3. Create a simple `middleware.ts` file in your project root:

```typescript
import { asgardeoMiddleware } from '@asgardeo/nextjs/middleware';

export default asgardeoMiddleware;

export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
};
```

### Option 2: Middleware-based Configuration

2. Then create a `middleware.ts` file in your project root to handle authentication:

```typescript
import { createAsgardeoMiddleware } from '@asgardeo/nextjs/middleware';

const middleware = createAsgardeoMiddleware({
baseUrl: process.env.NEXT_PUBLIC_ASGARDEO_BASE_URL,
clientId: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_ID,
clientSecret: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_SECRET,
afterSignInUrl: 'http://localhost:3000',
});

export { middleware };

export const config = {
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};
```

3. Add `SignInButton` and `SignOutButton` buttons to your app

```tsx
import styles from './page.module.css';
import {SignInButton, SignedIn, SignOutButton, SignedOut} from '@asgardeo/nextjs';

export default function Home() {
return (
<div className={styles.page}>
<main className={styles.main}>
<div className={styles.ctas}>
<SignedOut>
<SignInButton className={styles.primary}>Sign In</SignInButton>
</SignedOut>
<SignedIn>
<SignOutButton className={styles.secondary}>Sign Out</SignOutButton>
</SignedIn>
</div>
</main>
</div>
);
}
```

## Server-side Usage

You can access the Asgardeo client instance in server actions and other server-side code:

```typescript
import { getAsgardeoClient } from '@asgardeo/nextjs/server';

export async function getUserProfile() {
const client = getAsgardeoClient();
const user = await client.getUser();
return user;
}
```
Get started with Asgardeo in your Next.js application in minutes. Follow our [Next.js Quick Start Guide](https://wso2.com/asgardeo/docs/quick-starts/nextjs/) for step-by-step instructions on integrating authentication into your app.

## Architecture
## API Documentation

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.
For complete API documentation including all components, hooks, and customization options, see the [Next.js SDK Documentation](https://wso2.com/asgardeo/docs/sdks/nextjs/overview).

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
64 changes: 5 additions & 59 deletions packages/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,11 @@
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
</div>

## Installation

```bash
# Using npm
npm install @asgardeo/node

# or using pnpm
pnpm add @asgardeo/node

# or using yarn
yarn add @asgardeo/node
```

## Quick Start

```javascript
import { AsgardeoNodeClient } from "@asgardeo/node";

// Initialize the client
const authClient = new AsgardeoNodeClient({
clientId: "<your_client_id>",
clientSecret: "<your_client_secret>",
baseUrl: "https://api.asgardeo.io/t/<org_name>",
callbackURL: "http://localhost:3000/callback"
});

// Example Express.js integration
import express from "express";
const app = express();

// Login endpoint
app.get("/login", (req, res) => {
const authUrl = authClient.getSignInUrl();
res.redirect(authUrl);
});

// Callback handler
app.get("/callback", async (req, res) => {
try {
const { code } = req.query;
const tokens = await authClient.exchangeAuthorizationCode(code);
// Store tokens and redirect to home page
res.redirect("/");
} catch (error) {
res.status(500).send("Authentication failed");
}
});

// Get user info
app.get("/userinfo", async (req, res) => {
try {
const userInfo = await authClient.getUserInfo();
res.json(userInfo);
} catch (error) {
res.status(401).send("Unauthorized");
}
});
```
> [!IMPORTANT]
> ⚠️ Do not directly use this in your applications.
> `@asgardeo/node` is a framework agnostic SDK that provides core authentication functionalities.
> For framework-specific integrations, consider using the dedicated SDKs such as `@asgardeo/express`, etc.

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
15 changes: 1 addition & 14 deletions packages/nuxt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
</div>

## Installation

```bash
# Using npm
npm install @asgardeo/nuxt

# or using pnpm
pnpm add @asgardeo/nuxt

# or using yarn
yarn add @asgardeo/nuxt
```

## License

Apache-2.0
Licenses this source under the Apache License, Version 2.0 [LICENSE](./LICENSE), You may not use this file except in compliance with the License.
Loading
Loading