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

@activityplug/mastodon-base

v1.0.2

Published

Shared Mastodon-compatible API adapter foundation for ActivityPlug.

Readme

@activityplug/mastodon-base

@activityplug/mastodon-base is the shared implementation for ActivityPlug adapters that target Mastodon-compatible HTTP APIs. It maps common OAuth, instance, account, post, timeline, search, media, poll, notification, list, follow-request, filter, scheduled-post, social, and streaming operations.

This package is intended for adapter authors. Applications connecting to Mastodon, Pleroma or Akkoma, or Hollo should install the corresponding ActivityPlug adapter instead.

Installation

pnpm add @activityplug/mastodon-base @activityplug/core ky

@activityplug/core and ky are peer dependencies. Node.js 26 or newer is required, and all three packages use ECMAScript modules.

The package root is the supported public entry point:

import * as activityplug from "@activityplug/mastodon-base";

Creating a compatible adapter

Provide stable metadata and the software names accepted by the adapter:

import { createActivityPlugClient } from "@activityplug/core";
import { createMastodonBaseAdapter } from "@activityplug/mastodon-base";

const adapter = createMastodonBaseAdapter({
  id: "example-compatible",
  displayName: "Example Compatible",
  kind: "mastodon-compatible",
  supportedSoftware: ["example-compatible"],
  supportsRefreshToken: true,
});

const client = createActivityPlugClient({
  adapter,
  origin: "https://social.example",
});

console.log(client.adapter.metadata);

Add a remoteAuthority before calling a remote client operation. See the @activityplug/core README for the transport boundary.

createMastodonBaseAdapter() accepts the following compatibility options:

  • supportsRefreshToken enables the OAuth refresh strategy.
  • instanceEndpointRequired controls fallback when the Mastodon instance endpoint is unavailable.
  • supportsLocalVisibility adds visibility.local to accepted post inputs.
  • quoteStatusParameter maps quote creation through quoted_status_id or quote_id.
  • detectedCapabilities returns instance-specific decisions after software detection.
  • webSocket enables timeline and notification streaming.
  • streamingAuthentication selects authorization-header or websocket-subprotocol.

Use these options only when the target software has the corresponding remote contract. A product-specific adapter can extend or replace returned operation groups when its API differs from the base implementation.

Public API

The package root exports:

  • createMastodonBaseAdapter().
  • MastodonBaseAdapterOptions, detected-software, streaming, transport, and remote response types.
  • Mapping helpers including accountFromResponse(), postFromResponse(), and relationshipFromResponse().
  • Transport helpers including clientFor(), requestJson(), requestResponse(), requestVoid(), tokenHeader(), and invalidRemoteResponse().

The response types describe accepted remote fields. They are not normalized ActivityPlug entities. Mapping helpers validate required fields and preserve the source payload in normalized entities' raw property.

Capabilities and limitations

The base metadata contains explicit static decisions. Several operations start as unknown because support depends on detected software and version, including post editing, post history, media upload and deletion, notification unread counts, and filter v2 endpoints. Derived adapters should return instance-specific decisions through detectedCapabilities.

The base does not map post context, quote listing, translation, media lookup, URL media ingestion, grouped notifications, bookmark folders, emoji reactions, or conversation streaming. Quote creation is enabled only when quoteStatusParameter is configured.

Streaming requires an injected WebSocketFactory; no global WebSocket is used. The factory receives the public operation and may receive an authorization value. It must enforce the deployment's origin and network policy. A streaming endpoint advertised by an instance can have a different origin and can therefore require a matching remote credential grant.

Adapter implementation requirements

  • Keep adapter IDs stable. Opaque IDs and page cursors bind to the ID.
  • Use the operation name supplied by ActivityPlug when making remote requests.
  • Preserve exact remote cursors; do not substitute entity IDs.
  • Map unsupported behavior to a capability decision and ActivityPlugError("UNSUPPORTED_OPERATION", ...).
  • Validate remote responses before constructing normalized entities.
  • Do not infer feature support from a related Mastodon-compatible product.

See Adapter development for the complete implementation contract and Adapters and capabilities for the project-level support matrix.

License

Licensed under Apache-2.0 OR MIT. See LICENSE-APACHE and LICENSE-MIT.