Masto.js Versions Save

🐘 Universal Mastodon API client for JavaScript

v6.2.0

8 months ago

6.2.0 (2023-08-25)

Features

  • Support Mastodon v4.2.0 beta2 (3732a24)

v6.1.0

8 months ago

6.1.0 (2023-08-11)

Features

  • Add allowedMentions to v1.status.create (f307eff)
  • Mastodon 4.2.0 beta (88703ac)

Bug Fixes

  • Fix /v1/instance/translation_languages assertion (a531d3c)
  • Fix missing DefaultPaginationParams export (1894934)
  • Remove port number from admin username (f5d83e1)

Chores

v6.0.6

8 months ago

6.0.6 (2023-08-10)

Bug Fixes

  • Add missing group, limited, noindex attributes to Account (3294a8d)
  • test: Remove port number from OAuth grant (d095916)

v6.0.5

9 months ago

6.0.5 (2023-08-02)

Chores

  • docs: Update examples and docs (a3908d7)

v6.0.4

9 months ago

6.0.4 (2023-08-01)

Bug Fixes

  • Handle camelCase selection in proxy as an exception (df6e78b)
  • Remove parse-link-header and restore original implementation (f8215af)

v6.0.3

9 months ago

6.0.3 (2023-07-30)

Bug Fixes

  • Fix dispatch to return non-promise value (9fb38e7)

v6.0.2

9 months ago

6.0.2 (2023-07-28)

Bug Fixes

  • Fix Paginator#setDirection to return a new instance (b004e95)

Chores

  • ci: Integrate CI workflow configurations (4c5d57b)

v6.0.1

9 months ago

6.0.1 (2023-07-27)

Bug Fixes

  • Add missing exports for error classes (6dc0937)

Chores

  • deps-dev: bump @rollup/plugin-commonjs from 25.0.2 to 25.0.3 (9ce1eee)
  • deps-dev: bump @typescript-eslint/eslint-plugin (a20d9c5)
  • deps-dev: bump @typescript-eslint/parser from 5.60.1 to 5.62.0 (0bc86e5)
  • deps-dev: bump rollup from 3.26.0 to 3.26.3 (6b108f3)
  • deps: bump semver from 5.7.1 to 5.7.2 (8b682c6)
  • deps: Move Undici to devDependencies (237cb71)
  • Update README.md [skip ci] (32daa9c)

v6.0.0

9 months ago

Recent social media trends have transformed Mastodon's environment. Specifically, tighter API restrictions and the ending of automated accounts on other platforms highlight the need for a similar library in the Fediverse.

This release contains several updates necessary to more easily develop Mastodon clients and bot accounts.

Constructor Changes

// Pre v6
const masto = await login({
  url: "https://example.com",
  accessToken: "TOKEN"
})
// v6
const rest = createRestAPIClient({
  url: "https://example.com",
  accessToken: "TOKEN"
})
const ws = createStreamingAPIClient({
  streamingApiUrl: "wss://example.com",
  accessToken: "TOKEN"
})

The functions for creating clients have been changed to synchronous functions, and separate functions are now provided for the Streaming API and the REST API.

Change endpoint specification method

// Pre v6
masto.v1.accounts.follow("123");
masto.v2.media.update("123", { description: "description"});
masto.v1.timelines.listHashtag("mastodon");
// v6
masto.v1.accounts.$select("123").follow()
masto.v2.media.$select("123").update({ description: "description"});
masto.v1.timelines.hashtag.$select("mastodon").list();

Prior to v6, Masto.js had inconsistent property names indicating endpoints, with some endpoints using one word and others using two word method names. Also, endpoints whose path contained the ID of an entity received this as an argument, and the correspondence with the URL was ambiguous.

In v6, property names have been significantly revamped to provide a more consistent API for each endpoint. Basically, for the API /api/foo/bar/baz, an API foo.bar.baz is provided, with slashes replaced by dots.

Also, for endpoints that include path as an ID, a method $select is provided instead of taking the ID as an argument. This clarifies naming conventions and reduces bundle size.

The HTTP methods GET, POST, PATCH, and DELETE are supported as before with methods fetch, create, update, and remove. The list method is provided for endpoints that support pagination. As an exception, endpoints whose path ends with a verb (/follow, /add) will use that verb regardless of the HTTP method.

Improvements to the Streaming API

// Pre v6
const connect = () => {
  const stream = masto.streamPublic();
  stream.on("update", (event) => {
    ...
  });
  stream.ws.on("close", () => {
    connect();
  });
}
connect();

// v6
for await (const entry of masto.public.subscribe()) {
  ...
}

Prior to v6, Masto.js provided a streaming API using EventEmitter, which has been revamped to an API using Async Iterator. For more information on the benefits of Async Iterator, see this article.

In addition, to avoid overloading the Mastodon instances, we have changed to use multiplexed connections. This allows all subscriptions to share one WebSocket connection.

In addition, starting with v6, we have added the ability to automatically reconnect using exponential backoff in the event of a WebSocket connection error. This makes it easier to develop bot accounts and other applications that require real-time response.

What's next?

  • Support for Mastodon forks by adding Plugin functionality.
  • Expanded documentation. We will add individual articles, in addition to auto-generated ones.
  • Catch up on the latest JavaScript, including Explicit Resource Management and Iterator helpers.
  • Streaming support via EventStream
  • Support for Rate limit

6.0.0 (2023-07-27)

⚠ BREAKING CHANGES

  • Drop Node.js 16 support
  • Use ts-custom-error
  • Change WebSocket to AsyncIterator
  • Use Proxy API to reduce bundle size
  • Eliminate version check feature Idea: Drop version check feature #883
  • Remove SubscriptionPolicy, api.v1.admin.{account, report, domainEmailBlocks}

Features

  • Add setDirection and getDirection to paginator (2ad2da7)
  • Add ability to use custom WebSocket implementation (6e410ce)
  • Change WebSocket to AsyncIterator (fcdc5ec)
  • Use Proxy API to reduce bundle size (6e61c3d)
  • websocket: Add retry option (4b06ae1)
  • websocket: Support auto retry (fe47102)

Bug Fixes

  • Add type guard to Notification (26e0684)
  • build: Fix releaserc to run only in main branch (bc3d297)
  • Fix /accounts/update_credentials encoding (31ad84d)
  • Fix constructor types (2864d17)
  • Fix streaming timelines test (ddbb022)
  • Map app.verifyCredentials action type (212f4c0)

Chores

  • Add detectOpenHandles option (d8625b1)
  • Add sideEffects: [secure] (029544c)
  • Add unsubscribe method (30a0a95)
  • Auto-set encoding (604c3d6)
  • build: Use ES Module for config files (d9806ed)
  • Bump dependencies (5d14b67)
  • Clean up dependencies (64b62ba)
  • config: Segregate ws and rest configs (fc23e5d)
  • docs: Update CONTRIBUTING.md (c48a03b)
  • docs: Update example (da940be)
  • Drop Node.js 16 support (9cc1286)
  • Eliminate version check feature Idea: Drop version check feature #883 (68448ff)
  • Fix events test (c34a0d0)
  • Fix naming convention (4c2cf74)
  • Remove qs module (a00f3b2)
  • Remove SubscriptionPolicy, api.v1.admin.{account, report, domainEmailBlocks} (a1c727b)
  • Rename select to $select (0aa23ca)
  • rest: Restore auto media awaiting (31e20e4)
  • Revert target and module to ES6 (1bab465)
  • Segregate rest and streaming directory (#915) (e42295f)
  • Tag 6.0.0 alpha7 (a25b80c)
  • Tag 6.0.0-alpha.4 (4fbfde0)
  • Tag Alpha 1 (0fc1c4b)
  • Tag alpha 2 (ba36be1)
  • Tag alpha.0 (1d28068)
  • test: Enable concurrent test (fd8f203)
  • test: Improve test readability (6079201)
  • test: Override tsconfig in jest.config (ac89a3f)
  • tests: Add tests for WebSocket and Proxy API (507fe44)
  • tests: Create token on demand (cc7e15f)
  • test: Set max-workers on CI (4f370eb)
  • test: Use --report-unused-disable-directives (bc4a94a)
  • test: Use maxWorkers=1 temporarily (61759ff)
  • Use ts-custom-error (d439af9)

v5.11.4

9 months ago

5.11.4 (2023-07-15)

Bug Fixes