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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kacoon/efihub-client

v1.1.0

Published

JavaScript/TypeScript SDK for EFIHUB API using OAuth2 Client Credentials Flow

Readme

EFIHUB JS/Node Client

Introduction

EFIHUB client for Node.js that authenticates using OAuth 2.0 Client Credentials and exposes:

  • A lightweight HTTP client (GET/POST/PUT/DELETE) with automatic token caching and retry on 401
  • Storage module to upload files and get public URLs
  • Websocket module to dispatch real-time events to channels

Designed for server-side apps only—do not expose your client secret to browsers.

Installation

npm install @kacoon/efihub-client
# or
yarn add @kacoon/efihub-client
# or
pnpm add @kacoon/efihub-client

Configure environment:

export EFIHUB_CLIENT_ID=your_client_id
export EFIHUB_CLIENT_SECRET=your_client_secret
export EFIHUB_TOKEN_URL=https://efihub.morefurniture.id/oauth/token
export EFIHUB_API_URL=https://efihub.morefurniture.id/api

Authentication

  • Uses OAuth 2.0 Client Credentials to obtain an access token from EFIHUB_TOKEN_URL
  • Token is cached until expiry; on 401, the client clears the cache and retries once
  • Config keys: clientId, clientSecret, tokenUrl, apiBaseUrl

Create a client:

import { EfihubClient } from "@kacoon/efihub-client";

const efihub = new EfihubClient({
  clientId: process.env.EFIHUB_CLIENT_ID!,
  clientSecret: process.env.EFIHUB_CLIENT_SECRET!,
  tokenUrl: process.env.EFIHUB_TOKEN_URL, // optional
  apiBaseUrl: process.env.EFIHUB_API_URL, // optional
});

Http client module

Use the instance directly for simple calls.

// GET with query params
const res1 = await efihub.get("/user", { params: { page: 1 } });

// POST JSON
const res2 = await efihub.post("/orders", { sku: "ABC", qty: 2 });

// PUT
const res3 = await efihub.put("/orders/123", { qty: 3 });

// DELETE
const res4 = await efihub.delete("/orders/123");

TypeScript example:

interface Order {
  id: number;
  qty: number;
}
const resp = await efihub.get<Order>("/orders/123");
const order = resp.data; // typed

Storage module

Common server use case: upload a file and get its public URL.

// Upload to a folder; end with '/' to auto-generate a filename on server
const url = await efihub
  .storage()
  .upload("uploads/" /* dest */, "/path/to/local.jpg");
// url is string | null

All available helpers:

await efihub.storage().upload("uploads/" /* dest */, "/path/to/local.jpg"); // => string | null
await efihub.storage().exists("uploads/photo.jpg"); // => { exists: boolean }
await efihub.storage().size("uploads/photo.jpg"); // => { size: number | null }
await efihub.storage().delete("uploads/photo.jpg"); // => { deleted: boolean }

Notes:

  • upload(destPath, input, filename?) accepts string path to local file, Buffer, or Readable stream
  • Endpoints used: GET /storage/url|size|exists, POST /storage/upload, DELETE /storage/delete

Websocket module

Dispatch real-time events to channels (e.g. from a job or listener). Returns boolean indicating success:

const ok = await efihub.socket().dispatch({
  channel: "orders:updates",
  event: "OrderUpdated",
  data: { order_id: 123, status: "updated" },
});
console.log("dispatch ok:", ok);

Endpoint used: POST /api/websocket/dispatch with JSON { channel, event, data }.

License & Author

MIT © Imam Nurcholis. See LICENSE.

  • Author: https://github.com/imamnc
  • EFIHUB: https://efihub.morefurniture.id