Socket
Socket
Sign inDemoInstall

activitypub-types

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    activitypub-types

ActivityPub Typescript types


Version published
Maintainers
1
Install size
72.1 kB
Created

Readme

Source

ActivityPub Types

TypeScript typings for ActivityPub

Installation

npm i activitypub-types
# or
yarn add activitypub-types

How to use

Implemented and documented every structure from specification. You can use interfaces and extend them by yourself, or you can use specified fields types.

To specify object use correct type:

import { APAdd } from 'activitypub-types';
const addActivity: APAdd = {
    type: 'Add',
    actor: 'https://actor.example.org',
    // ...
}

Fields in types are pretty flexible, so you can pass different variations:

import { APAdd, APActor } from 'activitypub-types';

const actor1 = 'https://actor.example.org';

const actor2: APActor = {
    type: 'Person',
    id: 'https://actor2.example.org',
    summary: 'Another actor',
    inbox: 'https://actor2.example.org/inbox',
    outbox: 'https://actor2.example.org/outbox',
};

const addActivity: APAdd = {
    type: 'Add',
    actor: [actor1, actor2],
    // ...
};

To provide @context field use APRoot:

import { APAdd, APRoot } from 'activitypub-types';

const addActivity: APRoot<APAdd> = {
    '@context': 'https://www.w3.org/ns/activitystreams',
    type: 'Add',
    // ...
}

If you need field types themselves, you can import as well:

import { TypeField, NameField } from 'activitypub-types';

interface APExample {
    type: TypeField;
    name?: NameField;
    // ...
}

Changelog

v1.1.0

  • Update activities and documents types (#3, by @Saiv46)
  • Add APRoot type and removed @context from APObject (#5)
  • Improve AP documentation (#3, by @Saiv46)
  • Update README docs
  • Refactor (#3, by @Saiv46)

v1.0.3

  • Use orderedItems instead of items in OrderedCollection (#1, by @RangerMauve)

License

MIT

Keywords

FAQs

Last updated on 28 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc