Skip to content

Commit bcd3d78

Browse files
Trigger commit
1 parent c5c5077 commit bcd3d78

File tree

11 files changed

+37
-4793
lines changed

11 files changed

+37
-4793
lines changed

asynchronous-authorization/langchain-fastapi-py/frontend/bun.lock

Lines changed: 0 additions & 983 deletions
This file was deleted.

asynchronous-authorization/langchain-next-js/.env.example

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ AUTH0_AUDIENCE="https://your.domain.us.langgraph.app"
1212
AUTH0_SCOPE="openid profile email"
1313

1414
# Database configuration
15-
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_documents_db"
16-
17-
# Auth0 FGA
18-
FGA_STORE_ID=<your-fga-store-id>
19-
FGA_CLIENT_ID=<your-fga-store-client-id>
20-
FGA_CLIENT_SECRET=<your-fga-store-client-secret>
21-
FGA_API_URL=https://api.xxx.fga.dev
22-
FGA_API_AUDIENCE=https://api.xxx.fga.dev/
23-
FGA_API_TOKEN_ISSUER=auth.fga.dev
15+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/ai_documents_db"
2416

2517
# LANGGRAPH
2618
LANGGRAPH_API_URL=http://localhost:54367

asynchronous-authorization/langchain-next-js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ It's Vercel's free-tier friendly too! Check out the [bundle size stats below](#-
8888
This package has [@next/bundle-analyzer](https://www.npmjs.com/package/@next/bundle-analyzer) set up by default - you can explore the bundle size interactively by running:
8989

9090
```bash
91-
$ ANALYZE=true bun run build
91+
$ ANALYZE=true bun run build # or $ ANALYZE=true npm run build
9292
```
9393

9494
## License

asynchronous-authorization/langchain-next-js/bun.lock

Lines changed: 0 additions & 2004 deletions
This file was deleted.

asynchronous-authorization/langchain-next-js/src/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function middleware(request: NextRequest) {
1616
const { origin } = new URL(request.url);
1717
const session = await auth0.getSession(request);
1818

19-
// user does not have a session — redirect to login
19+
// user does not have a session — redirect to login page
2020
if (!session) {
2121
return NextResponse.redirect(`${origin}/auth/login`);
2222
}

asynchronous-authorization/vercel-ai-next-js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ It's Vercel's free-tier friendly too! Check out the [bundle size stats below](#-
8686
This package has [@next/bundle-analyzer](https://www.npmjs.com/package/@next/bundle-analyzer) set up by default - you can explore the bundle size interactively by running:
8787

8888
```bash
89-
$ ANALYZE=true bun run build
89+
$ ANALYZE=true bun run build # or $ ANALYZE=true npm run build
9090
```
9191

9292
## License

asynchronous-authorization/vercel-ai-next-js/bun.lock

Lines changed: 0 additions & 1625 deletions
This file was deleted.

asynchronous-authorization/vercel-ai-next-js/src/lib/tools/shop-online.ts

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,36 @@ import { getCIBACredentials } from '@auth0/ai-vercel';
44
import { withAsyncAuthorization } from '../auth0-ai';
55

66
export const shopOnlineTool = withAsyncAuthorization(
7-
tool({
8-
description: 'Tool to buy products online',
9-
inputSchema: z.object({
10-
product: z.string(),
11-
qty: z.number().int().positive(),
12-
priceLimit: z.number().positive().optional(),
13-
}),
14-
execute: async (args) => {
15-
const { product, qty, priceLimit } = args;
16-
const apiUrl = process.env.SHOP_API_URL;
17-
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
18-
19-
const credentials = getCIBACredentials();
20-
if (credentials?.accessToken) headers.Authorization = `Bearer ${credentials.accessToken}`;
7+
tool({
8+
description: 'Tool to buy products online',
9+
inputSchema: z.object({
10+
product: z.string(),
11+
qty: z.number().int().positive(),
12+
priceLimit: z.number().positive().optional(),
13+
}),
14+
execute: async (args) => {
15+
const { product, qty, priceLimit } = args;
16+
const apiUrl = process.env.SHOP_API_URL;
17+
const headers: Record<string, string> = { 'Content-Type': 'application/json' };
2118

22-
if (!apiUrl) return `Ordered ${qty} ${product}${priceLimit ? ` (≤ ${priceLimit})` : ''}`;
19+
const credentials = getCIBACredentials();
20+
if (credentials?.accessToken) {
21+
headers.Authorization = `Bearer ${credentials.accessToken}`;
22+
}
2323

24-
const res = await fetch(apiUrl, { method: 'POST', headers, body: JSON.stringify({ product, qty, priceLimit }) });
25-
if (!res.ok) throw new Error(`SHOP_API error ${res.status}: ${await res.text().catch(() => res.statusText)}`);
26-
return await res.text();
27-
},
28-
}));
24+
if (!apiUrl) {
25+
return `Ordered ${qty} ${product}${priceLimit ? ` (≤ ${priceLimit})` : ''}`;
26+
}
2927

28+
const res = await fetch(apiUrl, {
29+
method: 'POST',
30+
headers,
31+
body: JSON.stringify({ product, qty, priceLimit }),
32+
});
33+
if (!res.ok) {
34+
throw new Error(`SHOP_API error ${res.status}: ${await res.text().catch(() => res.statusText)}`);
35+
}
36+
return await res.text();
37+
},
38+
}),
39+
);

asynchronous-authorization/vercel-ai-node-js/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ OPENAI_API_KEY="openai-api-key"
4343
1. Install dependencies.
4444

4545
```sh
46-
bun install
46+
bun install # or npm install
4747
```
4848

4949
2. Update your user id in the sample [src/index.ts](./src/index.ts) provided.
@@ -61,7 +61,7 @@ OPENAI_API_KEY="openai-api-key"
6161
3. Running the example
6262

6363
```sh
64-
bun start
64+
bun start # or npm start
6565
```
6666

6767
## License

asynchronous-authorization/vercel-ai-node-js/bun.lock

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)