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

@dtelecom/x402-client

v0.1.3

Published

TypeScript SDK for dTelecom x402 gateway — buy credits and create WebRTC/STT/TTS sessions

Readme

@dtelecom/x402-client

TypeScript SDK for the dTelecom x402 gateway — buy credits with USDC and create WebRTC, STT, and TTS sessions for AI agents.

Uses the x402 HTTP payment protocol for on-chain micropayments on Base.

Install

npm install @dtelecom/x402-client @x402/fetch @x402/evm viem

@x402/fetch and @x402/evm are peer dependencies — they handle the 402 payment flow.

Quick Start

import { DtelecomGateway } from '@dtelecom/x402-client';
import { privateKeyToAccount } from 'viem/accounts';

const gateway = new DtelecomGateway({
  gatewayUrl: 'https://x402.dtelecom.org',
  account: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`),
});

// Buy credits ($0.10 USDC on Base)
const purchase = await gateway.buyCredits({ amountUsd: 0.10 });
console.log(`Credits: ${purchase.creditedMicrocredits}`);

// Create agent session (WebRTC + STT + TTS bundle)
const session = await gateway.createAgentSession({
  roomName: 'tutor-room-123',
  participantIdentity: 'ai-tutor',
  clientIdentity: 'student-1',
  clientIp: '203.0.113.42',       // optional — routes client to nearest SFU
  durationMinutes: 10,
  language: 'en',
});

console.log(session.webrtc.agent.token);   // JWT for agent's WebRTC connection
console.log(session.webrtc.client.token);  // JWT for client's WebRTC connection
console.log(session.stt.token);            // Token for STT server
console.log(session.tts.token);            // Token for TTS server

Wallet Support

The SDK accepts a viem LocalAccount — the standard interface for server-side wallets:

// Private key
import { privateKeyToAccount } from 'viem/accounts';
const account = privateKeyToAccount('0x...');

// Coinbase CDP server wallet
import { toAccount } from 'viem/accounts';
const account = toAccount(cdpServerAccount);

// AWS/GCP KMS via viem adapters
const account = await createKmsAccount({ ... });

API

Constructor

new DtelecomGateway({ gatewayUrl: string, account: LocalAccount })

Credits

| Method | Description | |--------|-------------| | buyCredits({ amountUsd }) | Purchase credits via x402 USDC payment on Base |

Account

| Method | Description | |--------|-------------| | getAccount() | Get account details and balance | | getTransactions({ limit?, offset? }) | List credit transactions | | getSessions({ limit?, offset?, status? }) | List sessions |

Agent Session (WebRTC + STT + TTS bundle)

| Method | Description | |--------|-------------| | createAgentSession({ roomName, participantIdentity, durationMinutes, language?, ttsMaxCharacters?, metadata?, clientIdentity?, clientIp? }) | Create bundled session | | extendAgentSession({ bundleId, additionalMinutes, additionalTtsCharacters? }) | Extend all sessions in bundle |

createAgentSession returns two WebRTC tokens — one for the agent and one for the client:

{
  bundleId: string;
  webrtc: {
    agent:  { sessionId: string; token: string; wsUrl: string };
    client: { sessionId: string; token: string; wsUrl: string };
  };
  stt: { sessionId: string; token: string; serverUrl: string };
  tts: { sessionId: string; token: string; serverUrl: string };
  expiresAt: string;
}

Standalone Sessions

| Method | Description | |--------|-------------| | createWebRTCToken({ roomName, participantIdentity, durationMinutes, metadata? }) | Create WebRTC session | | extendWebRTCToken({ sessionId, additionalMinutes }) | Extend WebRTC session | | createSTTSession({ durationMinutes, language? }) | Create STT session | | extendSTTSession({ sessionId, additionalMinutes }) | Extend STT session | | createTTSSession({ maxCharacters, language? }) | Create TTS session | | extendTTSSession({ sessionId, additionalCharacters }) | Extend TTS session |

Error Handling

import {
  GatewayError,              // Base error (any non-2xx)
  InsufficientCreditsError,  // 402 — not enough credits
  ConcurrencyLimitError,     // 429 — too many active sessions
  RateLimitError,            // 429 — too many requests
  NoCapacityError,           // 503 — no servers available
  PaymentError,              // x402 payment failed
} from '@dtelecom/x402-client';

try {
  await gateway.createAgentSession({ ... });
} catch (err) {
  if (err instanceof InsufficientCreditsError) {
    await gateway.buyCredits({ amountUsd: 1.00 });
  }
}

Pricing

| Service | Rate | Unit | |---------|------|------| | WebRTC | $0.001 | per minute | | STT | $0.006 | per minute | | TTS | $0.008 | per 1K characters |

1 USD = 1,000,000 microcredits.

License

MIT