@nextera.one/vnp-sdk
v1.0.0
Published
TypeScript SDK for VNP (Network Presence Layer) - Cryptographic Presence Verification
Downloads
34
Maintainers
Readme
@nextera.one/vnp-sdk
TypeScript SDK for VNP (Network Presence Layer) - cryptographic presence verification.
"IP moves packets. DNS finds locators. VNP proves presence."
Quick Start
1. Installation
npm install @nextera.one/vnp-sdk2. Usage Example
import {
createPresence,
computeVnpId,
signPresence,
validatePresence,
generateKeypair,
} from '@nextera.one/vnp-sdk';
// Generate a keypair
const keypair = await generateKeypair();
// Create a presence object
const presence = createPresence('device:sensor-001', ['net', 'log'], 5);
// Compute VNP-ID
const vnpId = computeVnpId(presence);
console.log('VNP-ID:', vnpId);
// Sign the presence
const signedPresence = await signPresence(presence, keypair);
// Validate
const result = validatePresence(signedPresence);
console.log('Valid:', result.ok);API Reference
Presence Objects
| Function | Description |
| ------------------------------------------------- | ----------------------------- |
| createPresence(subject, scopes?, ttl?, anchor?) | Create a new presence object |
| computeVnpId(presence) | Compute VNP-ID hash |
| signPresence(presence, keypair) | Sign with Ed25519 |
| validatePresence(presence) | Validate structure and timing |
| isPresenceValid(presence) | Check if within time window |
Resolution Records
| Function | Description |
| ------------------------------------------------ | ------------------------------- |
| createResolutionRecord(vnpId, ips, ttl?, ctx?) | Create RR binding VNP-ID to IPs |
| signResolutionRecord(rr, keypair) | Sign the resolution record |
| validateResolutionRecord(rr) | Validate RR structure |
Cryptographic Utilities
| Function | Description |
| --------------------------------------- | ------------------------ |
| generateKeypair() | Generate Ed25519 keypair |
| sign(message, privateKey) | Sign raw bytes |
| verify(signature, message, publicKey) | Verify signature |
| hash(data) | SHA-256 hash |
License
Apache-2.0
