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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@socialweb.coop/activitypub-behaviors

v0.5.2

Published

a dataset of behaviors[^1] described by the [ActivityPub](https://www.w3.org/TR/activitypub/) protocol.

Downloads

23

Readme

activitypub-behaviors

a dataset of behaviors[^1] described by the ActivityPub protocol.

[^1]: 'behavior' is used in the sense of RFC2119, which is cited by ActivityPub to define its requirements, recommendations, prohibitions, etc.

Have an Issue?

See ./issues/README.md (tl;dr PR your issue as a file in that directory).

Usage

Use as a command line tool

If you have npm installed, you can run this command to print all the behaviors as newline-delimited JSON to your console:

npx @socialweb.coop/activitypub-behaviors

If you want, you can pipe that ndjson to a tool like jq to wrangle the JSON, e.g. this shows the uuid and content of all the behaviors mentioning the bcc property that contain a MUST requirement level:

⚡  npx @socialweb.coop/activitypub-behaviors | jq '. | select(.content | test("bcc")) | select(.content | test("MUST")) | {uuid,content}'
{
  "uuid": "7f16b1b5-6c95-4d4c-83f1-3a3962a2e37c",
  "content": "When objects are received in the outbox..., the server MUST target and deliver to: The to, bto, cc, bcc or audience fields if their values are individuals or Collections owned by the actor.\n"
}
{
  "uuid": "e69ce2d6-2946-4513-b475-10690767a734",
  "content": "The server MUST remove the bto and/or bcc properties, if they exist, from the ActivityStreams object before delivery\n"
}
{
  "uuid": "f3725db1-1e6b-4d20-9cea-a49ef4291e9f",
  "content": "Any to, bto, cc, bcc, and audience properties specified on the object MUST be copied over to the new Create activity by the server.\n"
}
{
  "uuid": "08ed852d-f36c-47ba-992b-b211e35dbdca",
  "content": "Origin servers sending publicly addressed activities to sharedInbox endpoints MUST still deliver to actors and collections otherwise addressed (through to, bto, cc, bcc, and audience) which do not have a sharedInbox and would not otherwise receive the activity through the sharedInbox mechanism.\n"
}
{
  "uuid": "24dc401b-1d15-4232-b730-a31dd5e6c4a0",
  "content": "The server... MUST utilize the addressing originally stored on the bto / bcc properties for determining recipients in delivery.\n"
}

You can also install activitypub-behaviors globally so it is available on your PATH for repeat usage

npm install -g @socialweb.coop/activitypub-behaviors
# then `activitypub-behaviors` should print ndjson to stdout

Example

⚡  activitypub-behaviors | head -n1
{"id":"urn:uuid:fc2bfa75-8fd0-45e0-809d-7aa3970be8ae","type":"Behavior","name":"intransient objects must have unique global identifiers","content":"all objects distributed by the ActivityPub protocol MUST have unique global identifiers, unless they are intentionally transient\n","origin":{"source":"https://www.w3.org/TR/activitypub/","section":{"id":"https://www.w3.org/TR/activitypub/#obj-id","branch":[3,1]},"selector":{"type":"TextQuoteSelector","exact":"all objects distributed by the ActivityPub protocol MUST have unique global identifiers, unless they are intentionally transient (short lived activities that are not intended to be able to be looked up, such as some kinds of chat messages or game notifications).\n","prefix":"All Objects in [ActivityStreams] should have unique global identifiers. ActivityPub extends this requirement; \n","suffix":"These identifiers must fall into one of the following groups:\n"}},"uuid":"fc2bfa75-8fd0-45e0-809d-7aa3970be8ae","@context":["https://www.w3.org/ns/activitystreams","https://socialweb.coop/ns/testing/context.json"]}
EPIPE

Use as a JavaScript lib

You can use this package in your project by installing it with npm

npm install @socialweb.coop/activitypub-behaviors

Iterate all the behaviors

import { activityPubBehaviors } from '@socialweb.coop/activitypub-behaviors'
for await (const behavior of activityPubBehaviors) {
  console.log('ActivityPub behavior', behavior)
}

Iterate all the required behaviors (aka requirements)

import { activityPubRequirements } from '@socialweb.coop/activitypub-behaviors'
for await (const behavior of activityPubRequirements) {
  console.log('ActivityPub required behavior', behavior)
}

The Shape of Behavior

Each behavior corresponds to a file like ./behaviors/*.yaml. The syntax of the contents of thosre files is yaml.

Usage

with jc

jc can be useful for parsing the yamls. For example, this unix command lets you view a random requirement using jq.

⚡  ls behaviors/*.yaml | shuf | xargs cat | jc --yaml | jq '[.[] | { uuid, content, origin: .origin | {source,selector} }][:1]'
[
  {
    "uuid": "5e781a3a-4314-4ec6-b973-717456dc5da5",
    "content": "The server MUST only target the values of to, cc, and/or audience on the original object being forwarded, and not pick up any new addressees whilst recursing through the linked objects (in case these addressees were purposefully amended by or via the client).\n",
    "origin": {
      "source": "https://www.w3.org/TR/activitypub/",
      "selector": {
        "prefix": "The server SHOULD recurse through these values to look for linked objects owned by the server, and SHOULD set a maximum limit for recursion (ie. the point at which the thread is so deep the recipients followers may not mind if they are no longer getting updates that don't directly involve the recipient).\n",
        "exact": "The server MUST only target the values of to, cc, and/or audience on the original object being forwarded, and not pick up any new addressees whilst recursing through the linked objects (in case these addressees were purposefully amended by or via the client).\n",
        "suffix": "The server MAY filter its delivery targets according to implementation-specific rules (for example, spam filtering).\n"
      }
    }
  }
]

Developing

Each behavior corresponds to an entry in ./behaviors whose file name is like {uuid}.yaml.

Testing

Run the linkml validation with ./scripts/linkml-validate-behaviors. No output means no errors. linkml is only used at validation time.

Run the node.js tests with npm test.