Skip to content

networld-to/fediverse-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Function Params Output Caching
getInstanceHost None fediverseHost (String) Not needed, local call
getWebfingerInfo forceFetch: boolean = false (optional) webfingerInfo (Object) Yes
getInstanceInfo forceFetch: boolean = false (optional) instanceInfo (Object) Yes
getAccountInfo forceFetch: boolean = false (optional) accountInfo (Object) Yes
getOutboxPosts None posts ([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