
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
@botparty/nextjs
Advanced tools
Next.js SDK for BotParty auth — middleware, server auth(), route handlers, SSR provider
Next.js SDK for BotParty auth — middleware, server auth(), auto route handlers, and SSR provider. Clerk-like DX for BotParty identity and payments.
npx @botparty/nextjs init
This interactive command will:
.envOptions:
npx @botparty/nextjs init --domain example.com # skip domain prompt
npx @botparty/nextjs init --force # re-register and regenerate
npx @botparty/nextjs init --jwks # host /.well-known/jwks.json instead of registering inline key
npm install @botparty/nextjs
All set automatically by npx @botparty/nextjs init:
BOTPARTY_AUTH_URL=https://id.botparty.club # defaults to this if omitted
BOTPARTY_CLIENT_ID=bp_xxx
BOTPARTY_CLIENT_ASSERTION_KEY=<ES256 PEM private key> # signs client assertions + service JWTs
BOTPARTY_DOMAIN=example.com # your verified domain (optional, defaults to VERCEL_PROJECT_PRODUCTION_URL)
The single BOTPARTY_CLIENT_ASSERTION_KEY does double duty:
client_assertion JWTs (RFC 7523 private_key_jwt)X-BotParty-Service JWTsSHA-256("bp-session-key:" + key)// app/api/botparty/[...botparty]/route.ts
export { GET, POST } from '@botparty/nextjs/handlers';
Handles /login, /callback, /me, /sign-out, /wallet, /ledger automatically.
// middleware.ts
import { botpartyMiddleware, createRouteMatcher } from '@botparty/nextjs/server';
const isPublic = createRouteMatcher(['/api/public(.*)', '/pricing', '/']);
export default botpartyMiddleware((auth, req) => {
if (!isPublic(req)) auth.protect();
});
export const config = { matcher: ['/((?!_next|.*\\..*).*)'] };
// app/layout.tsx
import { BotPartyProvider } from '@botparty/nextjs';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<BotPartyProvider>{children}</BotPartyProvider>
</body>
</html>
);
}
The provider is an async Server Component — it reads the session server-side and hydrates the client with zero waterfall.
import { auth } from '@botparty/nextjs/server';
export async function GET() {
const session = await auth();
if (!session.isAuthenticated) {
return new Response('Unauthorized', { status: 401 });
}
session.userId; // string | null
session.email; // string | null
session.name; // string | null
session.picture; // string | null
session.namespaceId; // string | null (bot namespace)
session.type; // 'human' | 'bot' | null
session.hasLinkedUser; // boolean
session.getToken(); // raw token string
// Helpers
session.protect(); // redirects if not authenticated
session.redirectToSignIn(); // explicit redirect
}
Inside botpartyMiddleware, the auth callback receives:
interface MiddlewareAuthObject {
isAuthenticated: boolean;
type: 'human' | 'bot' | null;
userId: string | null;
namespaceId: string | null;
email: string | null;
protect(): MiddlewareAuthObject; // redirects to login if not authed
redirectToSignIn(): never;
}
Use createPaymentGateway() to charge for API access via the x402 protocol. The gateway handles verification, payment creation, and settlement automatically.
Units: All amounts are integers in USDC atomic units (6 decimals). 1 USDC = 1,000,000 units.
import { createPaymentGateway } from '@botparty/nextjs/server';
const gateway = createPaymentGateway({ serviceName: 'My API' });
Domain and private key are read from env vars automatically (BOTPARTY_DOMAIN, BOTPARTY_CLIENT_ASSERTION_KEY). On Vercel, domain falls back to VERCEL_PROJECT_PRODUCTION_URL if BOTPARTY_DOMAIN is not set.
You can override any of these in the config object:
const gateway = createPaymentGateway({
domain: 'custom.example.com',
serviceName: 'My API',
privateKey: process.env.MY_CUSTOM_KEY!,
});
Charge a flat fee per request:
// app/api/bots/pay-per-call/route.ts
export async function POST(req: Request) {
const check = await gateway.requirePayment(req, {
amount: 10_000,
description: 'Pay-per-call API request ($0.01)',
});
if (!check.authorized) return check.response; // 402 with payTo link
const result = { message: 'Paid request successful!' };
await gateway.claim(check, {
amount: 10_000,
description: 'Pay-per-call API request',
});
return Response.json(result);
}
Request a budget upfront, bill actual cost after processing:
// app/api/bots/dynamic-payment/route.ts
export async function POST(req: Request) {
const check = await gateway.requireBudget(req, {
estimated: 5_000_000,
description: 'AI inference — estimated cost ($5.00)',
});
if (!check.authorized) return check.response; // 402
const actualCost = await doExpensiveWork();
await gateway.claim(check, {
amount: actualCost,
description: `AI inference — actual cost ($${(actualCost / 1_000_000).toFixed(6)})`,
});
return Response.json({ message: 'Done!', charged: actualCost });
}
requirePayment() checks for an approved payment via the facilitator402 with PAYMENT-REQUIRED header and a JSON body containing a payTo link to a /humans/{flowId} multi-step approval flowpayTo link, completes login + top-up + approvalrequirePayment() finds the approved payment, returns authorized: trueclaim() settles the payment via the facilitatorYour service has a domain identity — the ES256 key in BOTPARTY_CLIENT_ASSERTION_KEY that botparty init registered with the IdP. To call another BotParty service, use botpartyFetch, which attaches the right Authorization header. Pick a mode explicitly:
import { botpartyFetch } from '@botparty/nextjs/server';
// 1. domain — act AS your service (signed domain JWT). The peer's auth() sees
// type:'bot', namespaceId=<your domain>. Use for backend / machine calls.
const res = await botpartyFetch('https://peer.botparty.club/api/v1/thing', {
botpartyAuth: { as: 'domain' },
});
// 2. user — act ON BEHALF OF the signed-in user (forwards their access token).
// The peer sees the end user, not your service.
const res2 = await botpartyFetch('https://peer.botparty.club/api/v1/thing', {
botpartyAuth: { as: 'user' },
});
// 3. apiKey — use a stable bpk_ key (CI / standalone backend identities).
const res3 = await botpartyFetch('https://peer.botparty.club/api/v1/thing', {
botpartyAuth: { as: 'apiKey' }, // reads BOTPARTY_STABLE_API_KEY
});
How the peer verifies it: the receiving service's auth() resolves the Authorization: Bearer token — a domain JWT is verified against the issuer's IdP namespace JWKS (no shared secret, no extra hosting), a user access token against the IdP, and a bpk_ key via introspection.
Lower-level helpers are also exported: signDomainToken(opts) returns just the JWT, and botpartyAuthHeaders(mode, targetUrl?) returns just the { Authorization } header for use with non-fetch clients (axios, the AI SDK provider config, etc.).
LLM inference is the exception.
llm.botparty.club/v1/*routes straight to LiteLLM, which needs ansk-virtual key — not a domain JWT. Mint one once withnpx @botparty/nextjs add-service llm(it authenticates to the management API with your domain identity and writesLLM_API_KEYto.env). See docs/SERVICE-TO-SERVICE.md.
All hooks and components from @botparty/react are re-exported:
import {
useAuth, useUser, useWallet, useLedger,
SignedIn, SignedOut, HasLinkedUser,
UserButton, NamespaceBadge,
WalletBalance, TransactionList, TopUpButton, SpendingControls,
} from '@botparty/nextjs';
import { SignedIn, SignedOut, UserButton, WalletBalance } from '@botparty/nextjs';
export default function Dashboard() {
return (
<div>
<SignedIn>
<UserButton />
<WalletBalance />
</SignedIn>
<SignedOut>
<a href="/api/botparty/auth/login">Sign in</a>
</SignedOut>
</div>
);
}
__botparty_session 15min, __botparty_refresh 30d) encrypted with key derived from BOTPARTY_CLIENT_ASSERTION_KEYid.botparty.club/.well-known/jwks.jsonWhen you run npx @botparty/nextjs init in an empty directory, it scaffolds a complete demo with:
/) -- sign in button, feature cards/dashboard) -- protected route showing all SDK components:
<UserButton>, <NamespaceBadge>, <WalletBalance>, <TransactionList><TopUpButton>, <SpendingControls>botparty curlGET /api/bots/open -- accepts any authenticated botGET /api/bots/user-required -- requires namespace linked to human accountPOST /api/bots/pay-per-call -- $0.10/call with payment authorizationPOST /api/bots/dynamic-payment -- $5 authorization, $0.20/call| Path | Contents |
|---|---|
@botparty/nextjs | BotPartyProvider, all React hooks + components |
@botparty/nextjs/server | auth(), currentUser(), botpartyMiddleware, createRouteMatcher, session utils, botpartyFetch, botpartyAuthHeaders, signDomainToken |
@botparty/nextjs/handlers | GET, POST catch-all route handlers |
FAQs
Next.js SDK for BotParty auth — middleware, server auth(), route handlers, SSR provider
We found that @botparty/nextjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.