npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

witnium-vault-sdk

v0.1.7

Published

TypeScript SDK for the Witnium Vault API

Downloads

672

Readme

Witnium Vault SDK

A TypeScript SDK for interacting with the Witnium Vault API. Provides type-safe access to all API endpoints with cookie-based authentication for seamless browser integration.

Installation

npm install witnium-vault-sdk

Quick Start

import { WitniumVaultClient } from 'witnium-vault-sdk';

// Create a client
const client = new WitniumVaultClient({
  baseUrl: 'https://witniumvault.witnium.tech'
});

// Login (sets session cookie)
await client.login({
  email: '[email protected]',
  password: 'your-password'
});

// List files
const result = await client.files.list({ page: 1, limit: 20 });
if (result.success) {
  console.log('Files:', result.data.files);
}

Features

  • Type-safe: Full TypeScript support with generated types from OpenAPI spec
  • Cookie-based auth: Seamless browser integration with automatic session management
  • Generic + Convenience methods: Use client.get('/api/files') or client.files.list()
  • Self-documenting: Runtime endpoint registry for AI tools (Lovable, etc.)
  • Error handling: Structured error responses with typed error objects

Authentication

The SDK uses cookie-based authentication, which works automatically in browser environments:

// Login
await client.login({
  email: '[email protected]',
  password: 'password'
});

// Check authentication status
const status = await client.getAuthStatus();
if (status.authenticated) {
  console.log('Logged in as:', status.user?.email);
}

// Logout
await client.logout();

MFA Support

If the user has MFA enabled, provide the TOTP code:

await client.login({
  email: '[email protected]',
  password: 'password',
  totp: '123456' // From authenticator app
});

// Or use a backup code
await client.login({
  email: '[email protected]',
  password: 'password',
  backupCode: 'ABCD-EFGH-1234'
});

API Methods

Generic Methods

The SDK provides generic HTTP methods that work with any endpoint:

// GET request
const result = await client.get('/api/files', { page: '1', limit: '20' });

// POST request (search)
const result = await client.post('/api/search', {
  query: 'contract',
  path: '/documents'
});

// PUT request
const result = await client.put('/api/files', {
  action: 'restore',
  fileId: 'file-123'
});

// DELETE request
const result = await client.delete('/api/files', { id: 'file-123' });

Convenience Methods

For common operations, use the typed convenience methods:

Files

// List files with pagination
const files = await client.files.list({ page: 1, limit: 20 });

// Get a specific file
const file = await client.files.get('file-123');

// Delete a file (soft delete)
await client.files.delete('file-123');

// Permanently delete
await client.files.delete('file-123', true);

// Restore a deleted file
await client.files.restore('file-123');

// Get version history
const history = await client.files.getHistory('file-group-123');

Search

// Simple search
const results = await client.search.query('contract');

// Search with filters
const results = await client.search.query('invoice', {
  fileTypes: ['pdf', 'docx'],
  dateRange: { from: '2024-01-01' },
  folderPath: '/documents',
  limit: 20
});

Evidence Binders

// List binders
const binders = await client.evidenceBinders.list();

// Create a binder
const binder = await client.evidenceBinders.create({
  name: 'Q1 2024 Contracts',
  description: 'All contracts signed in Q1 2024'
});

// Export a binder
const exportJob = await client.evidenceBinders.export('binder-123', 'pdf');

Workspace

// Get audit logs
const logs = await client.workspace.getAuditLogs({
  page: 1,
  limit: 50,
  eventType: 'file.upload'
});

// Get folder tree
const tree = await client.workspace.getFolderTree();

// Get usage statistics
const usage = await client.workspace.getUsage();

Error Handling

All methods return an ApiResult type that indicates success or failure:

const result = await client.files.get('invalid-id');

if (result.success) {
  console.log('File:', result.data.file);
} else {
  console.error('Error:', result.error.error);
  console.error('Status:', result.error.status);
  console.error('Code:', result.error.code);
}

For authentication errors, you can use the WitniumApiError class:

import { WitniumApiError } from 'witnium-vault-sdk';

try {
  await client.login({ email: '[email protected]', password: 'wrong' });
} catch (error) {
  if (error instanceof WitniumApiError) {
    if (error.isUnauthorized()) {
      console.log('Invalid credentials');
    }
    if (error.code === 'MFA_REQUIRED') {
      console.log('MFA code needed');
    }
  }
}

Endpoint Registry (For AI Tools)

The SDK includes a runtime endpoint registry for AI tools like Lovable:

import { EndpointRegistry } from 'witnium-vault-sdk';

// Get info about an endpoint
const info = EndpointRegistry.getEndpoint('/api/files');
console.log(info?.methods.GET?.description);
// Output: "List files in the current workspace"

// List all endpoints
const endpoints = EndpointRegistry.listEndpoints();

// Find endpoints by tag
const authEndpoints = EndpointRegistry.findByTag('Auth');

// Search endpoints
const fileEndpoints = EndpointRegistry.search('upload');

// Get a summary for AI context
const summary = EndpointRegistry.getSummary();
console.log(summary);
// Output: Markdown-formatted list of all endpoints

Configuration

const client = new WitniumVaultClient({
  // Required: API base URL
  baseUrl: 'https://witniumvault.witnium.tech',
  
  // Optional: Custom timeout (default: 30000ms)
  timeout: 60000,
  
  // Optional: Default headers for all requests
  defaultHeaders: {
    'X-Custom-Header': 'value'
  },
  
  // Optional: Custom fetch implementation (for testing)
  fetch: customFetchFunction
});

TypeScript Types

The SDK exports all types for use in your application:

import type {
  // Client types
  WitniumVaultClientConfig,
  ApiResult,
  ApiError,
  LoginCredentials,
  
  // API types
  FileMetadata,
  FilesListResponse,
  EvidenceBinder,
  SearchResult,
  
  // Resource options
  ListFilesOptions,
  SearchOptions,
  CreateBinderOptions,
} from 'witnium-vault-sdk';

Examples

Upload and Process a File

// Note: File uploads use multipart/form-data, not JSON
// Use the generic fetch or a form submission for uploads

// After upload, trigger AI processing
const result = await client.files.processAI('file-123');
if (result.success) {
  console.log('Processing started');
}

Export Evidence Binder

// Create and export a binder
const binder = await client.evidenceBinders.create({
  name: 'Legal Discovery',
  description: 'Documents for case #12345'
});

if (binder.success) {
  const exportJob = await client.evidenceBinders.export(
    binder.data.binder._id,
    'pdf'
  );
  
  if (exportJob.success) {
    console.log('Export started:', exportJob.data.exportId);
  }
}

Development

# Install dependencies
npm install

# Build the SDK
npm run build

# Generate types from OpenAPI spec
npm run generate-types

# Type check
npm run typecheck

License

MIT