0.3.1 • Published 3 months ago

@networld-to/fediverse-helper v0.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Fediverse Helper

Typescript/Javascript library that provides basic API calls and utility functions that are useful to interact with ActivityPub-based Fediverse instances. It supports also related protocols and specifications such as Webfinger.

Getting Started

# Not yet published
$ yarn add @networld-to/fediverse-helper

See the following usage example to get started.

import FediverseAccount from '@networld-to/fediverse-helper';

const fediAccount = new FediverseAccount('@user@instance.tld');

console.log(fediProfile.getInstanceHost());
fediProfile.getAccountInfo(this.email).then((profile) => {
  console.log(profile);
});

Functionality

The FediverseAccount class accepts the fediverse handle as input parameter during the instantiation. Everything else is derived from it by making the right calls and parsing the right data.

FunctionParamsOutputCaching
getInstanceHostNonefediverseHost (String)Not needed, local call
getWebfingerInfoforceFetch: boolean = false (optional)webfingerInfo (Object)Yes
getInstanceInfoforceFetch: boolean = false (optional)instanceInfo (Object)Yes
getAccountInfoforceFetch: boolean = false (optional)accountInfo (Object)Yes
getOutboxPostsNoneposts ([Object])No

The getHandleHost is an internal helper function that splits the fediverse handle into two parts and returns the hostname of it. For the instance host use the getInstanceHost function. The fediverse handle may only be an alias to the real instance.

Developers

# To run ./client/main.js after compiling the library (see ./dist output)
$ yarn run client @username@instance.tld

Alternatively run the steps manually.

# Make your changes in files under ./src/
$ yarn build
# see output under ./dist

# Change code under ./client/main.js and run it
$ node ./client/main.js @username@instance.tld