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

getimmutable

v0.3.0

Published

JavaScript/TypeScript SDK for the Immutable Audit Log API

Downloads

19

Readme

@getimmutable/sdk

TypeScript SDK for the Immutable Audit Log API. Zero dependencies — uses native fetch.

Installation

npm install @getimmutable/sdk

Requires Node.js 18+ or any modern browser.

Quick Start

import { Immutable } from '@getimmutable/sdk';

const immutable = new Immutable({
  apiKey: 'imk_your_api_key',
  baseUrl: 'https://your-instance.up.railway.app',
});

Track Events

// Simple event
await immutable
  .actor({ id: 'user_123', name: 'Jane Smith' })
  .track('invoice.created', 'Invoice');

// With metadata + targets
await immutable
  .actor({ id: 'user_123', name: 'Jane' })
  .target('Account', 'acc_source', 'Savings')
  .target('Account', 'acc_dest', 'Checking')
  .session('sess_abc123')
  .idempotencyKey('transfer_456')
  .track('transfer.completed', { type: 'Transfer', id: 'txn_789', name: 'Wire Transfer' }, {
    amount: 500,
    currency: 'USD',
  });

Batch Events

await immutable.client.trackBatch([
  { actor_id: 'user_1', action: 'page.viewed', session_id: 'sess_1' },
  { actor_id: 'user_1', action: 'button.clicked', session_id: 'sess_1' },
]);

Query Events

const { data, pagination } = await immutable.events.list({
  action: 'invoice.*',
  from: '2026-01-01',
  limit: 25,
});

const event = await immutable.events.get('event-uuid');

Verify Hash Chain

const result = await immutable.events.verify('2026-01-01', '2026-03-01');
console.log(result.valid); // true

Alerts

const alerts = await immutable.alerts.list({ rule_type: 'new_country' });

Exports

const { id } = await immutable.events.createExport({ from: '2026-01-01', to: '2026-03-01' });

// Poll for completion
const status = await immutable.events.getExport(id);
if (status.data.download_url) {
  // Download CSV
}

Next.js B2C Pattern

The SDK is designed for server-side use. The browser never touches Immutable directly — everything goes through your server. Here's the complete B2C flow for Next.js:

1. Track events in Server Actions

// app/actions/track.ts
'use server';
import { getServerSession } from 'next-auth';
import { immutable } from '@/lib/immutable'; // your singleton instance

export async function trackUserAction(action: string, metadata?: Record<string, unknown>) {
  const session = await getServerSession();
  if (!session?.user) return;

  await immutable
    .actor({ id: session.user.id, name: session.user.name })
    .session(session.sessionToken)
    .track(action, undefined, metadata);
}

2. Generate viewer tokens on the server

// app/api/viewer-token/route.ts
import { getServerSession } from 'next-auth';
import { immutable } from '@/lib/immutable';

export async function GET() {
  const session = await getServerSession();
  if (!session?.user) return Response.json({ error: 'Unauthorized' }, { status: 401 });

  // Token is scoped to the user's org — they can only see their own events
  const response = await immutable.client.createViewerToken({
    tenantId: session.user.orgId,
    ttl: 3600,
  });

  return Response.json(response);
}

3. Render the activity feed on the client

// app/components/activity-feed.tsx
'use client';

export function ActivityFeed({ token }: { token: string }) {
  return <audit-log-viewer token={token} theme="dark" />;
}

The pattern: User action in browser → hits your Next.js server → server calls Immutable SDK → event stored, alerts evaluated, session tracked → viewer reads back via scoped JWT. The browser never touches Immutable directly.

Error Handling

import { ImmutableError } from '@getimmutable/sdk';

try {
  await immutable.actor({ id: 'user_1' }).track('test');
} catch (error) {
  if (error instanceof ImmutableError) {
    console.log(error.statusCode);    // 422
    console.log(error.responseBody);   // { error: '...', violations: [...] }
  }
}

License

MIT