dog-and-duck.quack.quack

Validator for ActivityPub objects: if it walks like a duck, and it quacks like a duck…

**NOTE THAT the ActivityPub spec says

Servers SHOULD validate the content they receive to avoid content spoofing attacks

but in practice ActivityPub content collected in the wild bears only a hazy relationship to the spec, so this is difficult. I suspect that I may have to implement a *strict* dynamic variable, so that users can toggle some checks off.

activity?

(activity? x)

true iff x quacks like an activity, else false.

actor-or-uri?

(actor-or-uri? x)

true if x is either a URI or an actor.

TODO: I need to decide about whether to reify referenced objects before validation or after. After reification, every reference to an actor must be to an actor object, but before, may only be to a URI pointing to one.

actor-type?

macro

(actor-type? x)

Return true iff the x is a recognised actor type, else false.

actor-types

The set of types we will accept as actors.

There’s an explicit set of allowed actor types.

actor?

(actor? x)

Returns true if x quacks like an actor, else false.

NOTE THAT Section 4.1 of the spec says explicitly that

Actor objects MUST have, in addition to the properties mandated by 3.1 Object Identifiers, the following properties:

inbox A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor; see 5.2 Inbox. outbox An [ActivityStreams] OrderedCollection comprised of all the messages produced by the actor; see 5.1 Outbox.

However, none of the provided examples in the activitystreams-test-documents repository does in fact have these properties

collection-page?

(collection-page? x)

true iff x quacks like a page in a paged collection, else false.

collection?

(collection? x object-type)(collection? x)

true iff x quacks like a collection of type object-type, else false.

With one argument, will recognise plain collections and ordered collections, but (currently) not collection pages.

link?

(link? x)

true iff x quacks like a link, else false.

object?

(object? x)(object? x severity)

Returns true iff x is recognisably an ActivityStreams object.

NOTE THAT The ActivityStreams spec says:

All properties are optional (including the id and type)

But we are just not having that, because otherwise we’re flying blind. We shall reject objects lacking at least :type. Missing :id keys are tolerable because they represent transient objects, which we expect to handle.

NOTE THAT The ActivityPub spec says

Implementers SHOULD include the ActivityPub context in their object definitions

but in samples found in the wild they typically don’t.

ordered-collection-page?

(ordered-collection-page? x)

true iff x quacks like a page in an ordered paged collection, else false.

ordered-collection?

(ordered-collection? x)

true iff x quacks like an ordered collection, else false.

persistent-object?

(persistent-object? x)

true iff x is a persistent object.

Transient objects in ActivityPub are not required to have an id key, but persistent ones must have a key, and it must be an IRI (but normally a URI).

unordered-collection?

(unordered-collection? x)

true iff x quacks like an unordered collection, else false.

verb-type?

macro

(verb-type? x)

TODO: write docs

verb-types

The set of types we will accept as verbs.

There’s an explicit set of allowed verb types.