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

tm-hub-client

v1.0.8

Published

Unified TypeScript SDK for TM-Hub (IAM, Configs, Media, Notifications & Audit Logs)

Readme

tm-hub-client

Unified, isomorphic TypeScript Client SDK for TM-Hub (Centralized IAM, Remote Configs, Media Gateway, Push Notifications & Dedicated MongoDB Audit Logs).

npm version License: MIT

Features

  • Zero External Runtime Dependencies: Built entirely on native fetch and modern Web APIs.
  • Dual ESM & CommonJS Build: Seamlessly works in Node.js, Electron, Nuxt, Vite, and modern browsers.
  • First-Class TypeScript Support: 100% typed request payloads, responses, models, and error structures.
  • Automatic Token & Tenant Injection: Automatically injects X-App-Id and Authorization: Bearer <token>.
  • Silent Refresh (optional): Pass getRefreshToken + onTokensRefreshed to auto-retry once on 401.
  • Client-side Capability Helpers: hub.capabilities.has() / canAccessApp() / load() with dual-read aliases (media.write↔media.upload, logs.read↔apps.logs.read).
  • Complete Module Coverage:
    • auth: Login, Register, Me, Permissions (JWT claims), Update Profile, Change Password, Refresh token, Logout, Dynamic Route Tree, List/Revoke Sessions.
    • apps: List, Get, Create, Update, Delete (batch), Reorder.
    • configs: Get Public Configs, Get App Public Configs, Get App Configs, Update App Configs.
    • media: Cloudinary Upload Signatures, Folder Management, Asset Listing/Deletion & Renaming.
    • notifications: List In-App Notifications, Mark as Read, Mark All Read, Batch Delete, Web Push Subscribe/Unsubscribe, Trigger Notifications.
    • users: List (cursor pagination), Create, Update, and Delete app users.
    • roles: Role & Permission Matrix CRUD operations.
    • routes: Dynamic navigation system route management.
    • permissions: Read-only global capability catalog (§6.4).
    • docs: Reference docs content for the admin docs page (single source of truth lives in TM-Hub).
    • connections: Per-app provider credentials (list, save manual, quick connect, test, disconnect, OAuth start).
    • imports: Data import targets, preview, run and Google Sheets fetch (server-side proxy).
    • ai: AI provider catalogue, credentials, model catalogue, discovery and grants (R147).
    • logs / auditLogs: Query dedicated MongoDB audit history logs.

Hard delete endpoints (apps.delete, users.delete, roles.delete) require a root token on the TM-Hub server. Routes are soft-deleted server-side.


Installation

# Using pnpm
pnpm add tm-hub-client

# Using npm
npm install tm-hub-client

# Using yarn
yarn add tm-hub-client

Quick Start

import { createHubClient } from 'tm-hub-client'

const hub = createHubClient({
  baseUrl: 'https://hub.yourdomain.com', // TM-Hub instance URL
  appId: 'tm-tools',                    // Unique Satellite App identifier
  getAccessToken: () => localStorage.getItem('accessToken'),
  onUnauthorized: () => {
    // Handler when response is 401
    window.location.href = '/login'
  }
})

// 1. Fetch Remote Application Configs
const { data: configs } = await hub.configs.getAll()

// 2. Update Configs (Triggers deep diff audit logging in TM-Hub)
await hub.configs.update({
  APP_NAME: 'TM Tools Desktop',
  CLOUDINARY_CLOUD_NAME: 'my-cloud'
})

// 3. Get Media Signature for direct Cloudinary upload
const { data: sig } = await hub.media.getSignature({ folder: 'avatars' })

// 4. Query Audit History from Dedicated MongoDB Logger
const { data: auditLogs } = await hub.logs.list({ limit: 20 })

Nuxt 3/4 Composable Pattern

In your Nuxt project, create app/composables/useHub.ts:

import { createHubClient } from 'tm-hub-client'

export const useHub = () => {
  const config = useRuntimeConfig()
  const auth = useAuth()

  const client = createHubClient({
    baseUrl: config.public.hubUrl || 'http://localhost:4000',
    appId: config.public.hubAppId || 'my-app',
    getAccessToken: () => auth.accessToken.value,
    onUnauthorized: () => {
      auth.logout()
    }
  })

  return {
    client,
    auth: client.auth,
    apps: client.apps,
    configs: client.configs,
    media: client.media,
    notifications: client.notifications,
    users: client.users,
    roles: client.roles,
    routes: client.routes,
    permissions: client.permissions,
    capabilities: client.capabilities,
    logs: client.logs
  }
}

Building & Publishing to npm

# 1. Build dual ESM + CJS bundles and type declarations
pnpm build

# 2. Dry run publish verification
npm pack --dry-run

# 3. Publish to npm public registry
npm publish --access public

License

MIT © tuanmjnh