velocitytunedagenticx401
v1.0.3
Published
velocity tuned x401 for agent authentication and access
Readme
Velocity X402 Wrapper
Velocity x401 implementation for agent authentication and access
📦 Installation
Using npm:
npm install velocitytunedagenticx401User needs to handle token storage in V 1.0.0 on their own
Update will abstract the token handling on velocity infrastructure
//FIRST RUN
import { VelocityAgentAuth } from "velocitytunedagenticx401";
import { MongoClient } from "mongodb";
// USERS CAN STORE IT ANYWHERE ,HERE WE USE DB STORAGE
const mongo = new MongoClient("mongodb://localhost:27017");
await mongo.connect();
const db = mongo.db("authdb");
const agents = db.collection("agents");
let config = {
key: "agent wallet private key",
agent: "agent_v1",
required_mint: "TOKEN_CA_HERE",
mint_amount: "200.0"
};
let result = await VelocityAgentAuth(config);
console.log("New token:", result.token);
// SAVE TOKEN TO DB HERE AS AN EXAMPLE
await agents.updateOne(
{ agent: config.agent },
{ $set: { token: result.token } },
{ upsert: true }
);
//SECOND RUN
// USERS CAN STORE IT ANYWHERE ,HERE WE USE DB STORAGE
const mongo = new MongoClient("mongodb://localhost:27017");
await mongo.connect();
const db = mongo.db("authdb");
const agents = db.collection("agents");
//LOAD TOKEN FROM DB
const saved = await agents.findOne({ agent: "agent_v1" });
let config = {
agent: "agent_v1",
token: saved?.token || null // SEND IT BACK HERE
};
let result = await VelocityAgentAuth(config);
console.log("Authentication Result:", result);
