vaultx-sdk
v1.0.4
Published
Official VaultX SDK for interacting with the VaultX API
Maintainers
Readme
VaultX SDK
The official JavaScript SDK for interacting with the VaultX API. Easily fetch, read, write, upload, and delete files in your VaultX storage.
📦 Installation
npm install vaultx-sdk🚀 Usage Example
const VaultX = require("vaultx-sdk");
const sdk = new VaultX({
publicUserId: "your_public_user_id_here", // Replace with your actual publicUserId
});
(async () => {
try {
console.log("🚀 Testing VaultX SDK...");
// 🔍 FETCH folder contents
const files = await sdk.fetch("test-namespace");
console.log("✅ FETCH:", files);
// 📝 WRITE a text file
await sdk.write("test-namespace", "hello.txt", "Hello from VaultX SDK!");
console.log("✅ WRITE: hello.txt");
// 📖 READ file content
const content = await sdk.read("test-namespace", "hello.txt");
console.log("✅ READ:", content);
// 🔎 SINGLE file metadata
const file = await sdk.single("test-namespace", "hello.txt");
console.log("✅ SINGLE:", file);
// ❌ DELETE file
const del = await sdk.delete("test-namespace", ["hello.txt"]);
console.log("✅ DELETE:", del);
} catch (err) {
console.error("❌ SDK Test Error:", err.message);
}
})();📚 API Methods
sdk.fetch(folder)→ Get all files/folders inside a namespace.sdk.write(folder, fileName, content)→ Create or overwrite a file with text content.sdk.read(folder, fileName)→ Read content of a file (text or base64 for binary).sdk.single(folder, fileName)→ Get single file metadata.sdk.delete(folder, [files])→ Delete one or multiple files.sdk.upload(folder, file)→ Upload a binary file (usingFormData).
🔑 Authentication
You need a publicUserId from VaultX to use this SDK.
When you register or connect your app to VaultX, you’ll be assigned a publicUserId.
📄 License
This SDK is released under the MIT License.
