
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
nuabase-server-sdk
Advanced tools
Nuabase Server SDK to create short-lived JWT tokens for direct front-end LLM calls
Nuabase turns LLM prompts into type-safe functions and allows you to call them directly from your front-end. Set up your free account now at Nuabase.
This is the Server SDK (Node.js) intended only to generate short-lived JWT tokens, to be passed to the Nuabase front-end SDK. With this you can make authenticated LLM requests directly from your front-end.
Install the package:
npm install nuabase-server-sdk
# or
yarn add nuabase-server-sdk
Obtain a Signing Key Secret from the Nuabase Console.
This key is a secret and must be stored securely on your backend server. It must not be exposed to the client-side code. We recommend storing it as an environment variable named NUABASE_SIGNING_KEY_SECRET.
The Signing Key Secret is used by your backend to generate short-lived JWT tokens via this SDK.
import { NuaTokenGenerator } from 'nuabase-server-sdk';
// Initialize the generator with your signing key secret and the user ID
const generator = new NuaTokenGenerator({
signingKeySecret: process.env.NUABASE_SIGNING_KEY_SECRET!,
userId: 'user_123', // The ID of the user in your system
});
// Generate the token
const tokenData = generator.generate();
// tokenData contains:
// {
// access_token: "eyJhbGci...",
// expires_in: 180,
// expires_at: 1732398765
// }
console.log(tokenData.access_token);
You can integrate Nuabase into your Express application by creating an endpoint to serve the token.
POST /.well-known/nuabase/token).import express from 'express';
import { NuaTokenGenerator } from 'nuabase-server-sdk';
const app = express();
app.use(express.json());
// Mock authentication middleware
const authenticateUser = (req, res, next) => {
// Your authentication logic here
req.user = { id: 'user_123' };
next();
};
app.post('/.well-known/nuabase/token', authenticateUser, (req, res) => {
try {
const generator = new NuaTokenGenerator({
signingKeySecret: process.env.NUABASE_SIGNING_KEY_SECRET!,
userId: req.user.id,
});
const token = generator.generate();
res.json(token);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to generate token' });
}
});
app.listen(3000, () => console.log('Server running on port 3000'));
The typical workflow is:
POST /.well-known/nuabase/token).nuabase-server-sdk SDK to generate a token for that specific user.Tokens expire after 180 seconds by default. You can override the TTL by passing expirySeconds when instantiating NuaTokenGenerator:
const generator = new NuaTokenGenerator({
signingKeySecret: process.env.NUABASE_SIGNING_KEY_SECRET!,
userId: 'user_123',
expirySeconds: 300, // token will last for 5 minutes
});
Keep the expiration short to prevent abuse of leaked tokens. The Nuabase Client SDK will automatically refresh the token when it expires.
Bug reports and pull requests are welcome on GitHub at https://github.com/nuabase/ts-server
MIT
FAQs
Nuabase Server SDK to create short-lived JWT tokens for direct front-end LLM calls
The npm package nuabase-server-sdk receives a total of 2 weekly downloads. As such, nuabase-server-sdk popularity was classified as not popular.
We found that nuabase-server-sdk 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.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.