
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@nillion/nilai-ts
Advanced tools
A TypeScript SDK for the Nilai platform that provides delegation token management and OpenAI-compatible client functionality for accessing AI models through secure, decentralized infrastructure.
This project uses pnpm for dependency management.
# Install dependencies
pnpm install
import { NilaiOpenAIClient } from "@nillion/nilai-ts";
import "dotenv/config";
// Initialize client with API key from environment variables
const client = new NilaiOpenAIClient({
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
apiKey: process.env.NILLION_API_KEY,
});
// Make a chat completion request
const response = await client.chat.completions.create({
model: "meta-llama/Llama-3.1-8B-Instruct",
messages: [{ role: "user", content: "Hello! Can you help me with something?" }],
});
console.log(`Response: ${response.choices[0].message.content}`);
The easiest way to get started. Your API key is your private key.
import { NilaiOpenAIClient } from "@nillion/nilai-ts";
import "dotenv/config";
// Set up your API key in a .env file or environment variable
const client = new NilaiOpenAIClient({
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
apiKey: process.env.NILLION_API_KEY, // Your private key
});
// Make requests just like with OpenAI
const response = await client.chat.completions.create({
model: "meta-llama/Llama-3.1-8B-Instruct",
messages: [
{ role: "user", content: "Explain quantum computing in simple terms" },
],
});
console.log(response.choices[0].message.content);
To execute it:
pnpm i
pnpm exec tsx examples/0-api-key.ts
For more secure, distributed access where you want to separate server credentials from client usage.
import {
NilaiOpenAIClient,
DelegationTokenServer,
AuthType,
NilAuthInstance,
} from "@nillion/nilai-ts";
import "dotenv/config";
// Server-side: Create a delegation token server
const server = new DelegationTokenServer(process.env.NILLION_API_KEY, {
nilauthInstance: NilAuthInstance.SANDBOX,
expirationTime: 3600, // 1 hour validity
tokenMaxUses: 10, // Allow 10 uses
});
// Client-side: Initialize client for delegation token mode
const client = new NilaiOpenAIClient({
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
authType: AuthType.DELEGATION_TOKEN,
});
// Step 1: Client requests delegation
const delegationRequest = client.getDelegationRequest();
// Step 2: Server creates delegation token
const delegationToken = await server.createDelegationToken(delegationRequest);
// Step 3: Client uses the delegation token
client.updateDelegation(delegationToken);
// Step 4: Make authenticated requests
const response = await client.chat.completions.create({
model: "meta-llama/Llama-3.1-8B-Instruct",
messages: [
{ role: "user", content: "What are the benefits of decentralized AI?" },
],
});
console.log(response.choices[0].message.content);
To execute it:
pnpm i
pnpm exec tsx examples/1-delegation-token.ts
Create a .env
file for your credentials:
# .env file
NILLION_API_KEY=your-private-key-for-nilai
Then in your code:
import "dotenv/config";
import { NilaiOpenAIClient } from "@nillion/nilai-ts";
const client = new NilaiOpenAIClient({
baseURL: "https://nilai-a779.nillion.network/nuc/v1/",
apiKey: process.env.NILLION_API_KEY,
});
nilauth
environments.A server-side component responsible for:
An OpenAI-compatible client that:
DelegationTokenServer
or NilaiOpenAIClient
in API Key mode.To run all tests:
pnpm test
To run tests in watch mode:
pnpm test:watch
To run tests with coverage reporting:
pnpm test:coverage
This project uses Biome for linting and formatting.
Run formatting:
pnpm fmt
Run linting:
pnpm lint
Run all checks:
pnpm ci
src/
├── client.ts # NilaiOpenAIClient class
├── server.ts # DelegationTokenServer class
├── types.ts # Type definitions and Zod schemas
├── utils.ts # Utility functions
└── internal/
└── debug_client.ts # Debug client
FAQs
Nilai Typescript SDK
The npm package @nillion/nilai-ts receives a total of 18 weekly downloads. As such, @nillion/nilai-ts popularity was classified as not popular.
We found that @nillion/nilai-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.