NOVA SDK for JavaScript
A JavaScript/TypeScript SDK for interacting with the NOVA secure file-sharing on the NEAR blockchain. Provides encrypted, decentralized file storage using IPFS and NEAR smart contracts with group-based access control.
Features
π AES-256-CBC Encryption - Client-side encryption for data privacy
π IPFS Storage - Decentralized file storage via Pinata
βοΈ NEAR Blockchain - Immutable transaction records and access control
π₯ Group Management - Fine-grained access control with member authorization
π Key Rotation - Automatic key rotation on member revocation
π Composite Operations - Simplified high-level workflows
π¦ TypeScript Support - Full type definitions included
Installation
npm install nova-sdk-jsQuick Start
import { NovaSdk } from 'nova-sdk-js';
async function main() {
// Initialize SDK
const sdk = new NovaSdk(
'https://rpc.testnet.near.org',
'nova-contract.testnet',
'your_pinata_api_key',
'your_pinata_secret_key'
);
// Attach signer
await sdk.withSigner(
'ed25519:your_private_key',
'your-account.testnet'
);
// Upload encrypted file
const data = Buffer.from('Confidential data');
const result = await sdk.compositeUpload(
'project_alpha', // group_id
'alice.testnet', // user_id
data, // data buffer
'report.txt' // filename
);
console.log('β
Uploaded to IPFS:', result.cid);
console.log('π Transaction ID:', result.trans_id);
console.log('π File Hash:', result.file_hash);
// Retrieve and decrypt file
const retrieved = await sdk.compositeRetrieve(
'project_alpha',
result.cid
);
const content = retrieved.data.toString('utf8');
console.log('π Content:', content);
}
main().catch(console.error);Core Concepts
Groups
Groups provide isolated access control domains. Each group has:
A unique identifier (
group_id)An owner who manages membership
A shared encryption key
A list of authorized members
Access Control
Encryption
All data is encrypted client-side using AES-256-CBC:
256-bit symmetric keys
Random IV per encryption
PKCS7 padding
Keys stored encrypted on blockchain
Transaction Recording
Every file operation creates an immutable blockchain record:
API Overview
Initialization
Group Management
Key Management
File Operations
Utilities
Types
Environment Setup
For testing and development, set these environment variables:
Create a .env file:
Testing
Error Handling
The SDK uses a custom NovaError class:
Security Considerations
β οΈ Important Security Notes:
Private Keys - Never commit private keys to version control
Key Storage - Store encryption keys securely
IPFS Privacy - IPFS content is public; encryption is essential
Access Control - Verify user authorization before operations
Key Rotation - Revoked members cannot decrypt new content
Buffer Handling - Use Buffer for binary data to avoid encoding issues
NEAR Token Deposits
Some operations require NEAR token deposits:
registerGroup()- 0.1 NEARaddGroupMember()- 0.0005 NEARrevokeGroupMember()- 0.0005 NEARstoreGroupKey()- 0.0005 NEARrecordTransaction()- 0.002 NEAR
Ensure your account has sufficient balance before calling these methods.
Examples
Basic File Upload
Group Management
Transaction History
Building from Source
Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure all tests pass (
npm test)Submit a pull request
License
This project is licensed under the MIT License - see LICENSE file for details.
Resources
Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Last updated