vocabulary.scm
| 1 | ;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu> |
| 2 | ;;;; |
| 3 | ;;;; This library is free software; you can redistribute it and/or |
| 4 | ;;;; modify it under the terms of the GNU Lesser General Public |
| 5 | ;;;; License as published by the Free Software Foundation; either |
| 6 | ;;;; version 3 of the License, or (at your option) any later version. |
| 7 | ;;;; |
| 8 | ;;;; This library is distributed in the hope that it will be useful, |
| 9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | ;;;; Lesser General Public License for more details. |
| 12 | ;;;; |
| 13 | ;;;; You should have received a copy of the GNU Lesser General Public |
| 14 | ;;;; License along with this library; if not, write to the Free Software |
| 15 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | ;;;; |
| 17 | ;;;; |
| 18 | ;;;; |
| 19 | ;;;; Note that most of this file is a direct translation of the activitystreams |
| 20 | ;;;; vocabulary specification (esp. comments in type and property) which |
| 21 | ;;;; is under these terms: |
| 22 | ;;;; |
| 23 | ;;;; Copyright © 2017 Activity Streams Working Group, IBM & W3C® (MIT, |
| 24 | ;;;; ERCIM, Keio, Beihang). W3C liability, trademark and permissive |
| 25 | ;;;; document license rules apply. |
| 26 | ;;;; |
| 27 | ;;;; You should have received a copy of the Permissive Document License along |
| 28 | ;;;; with this library; if not, that document license is accessible online at: |
| 29 | ;;;; https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document |
| 30 | ;;;; |
| 31 | ;;;; The origin document used to develop this can be found at: |
| 32 | ;;;; https://www.w3.org/TR/activitystreams-vocabulary |
| 33 | |
| 34 | (define-module (activitypub vocabulary) |
| 35 | #:use-module ((activitystreams vocabulary) #:prefix as:) |
| 36 | #:use-module (activitystreams ontology) |
| 37 | #:use-module (activitystreams predicates) |
| 38 | #:use-module (ice-9 match) |
| 39 | #:use-module (jsonld json) |
| 40 | #:use-module (web uri) |
| 41 | #:export (activitypub-ontology)) |
| 42 | |
| 43 | (define-public source |
| 44 | (build-as-property |
| 45 | "source" as:Object json-object? |
| 46 | #:comment |
| 47 | "The source property is intended to convey some sort of source from which |
| 48 | the content markup was derived, as a form of provenance, or to support future |
| 49 | editing by clients. In general, clients do the conversion from source to |
| 50 | content, not the other way around.")) |
| 51 | |
| 52 | (define-public content |
| 53 | (build-as-property |
| 54 | "content" source string-or-lang-string?)) |
| 55 | |
| 56 | (define-public mediaType |
| 57 | (build-as-property |
| 58 | "mediaType" source mime-type?)) |
| 59 | |
| 60 | (define-public inbox |
| 61 | (build-as-property |
| 62 | "inbox" as:Object as:OrderedCollection |
| 63 | #:comment "The inbox stream contains all activities received by the actor. |
| 64 | The server should filter content according to the requester's permission. In |
| 65 | general, the owner of an inbox is likely to be able to access all of their |
| 66 | inbox contents. Depending on access control, some other content may be |
| 67 | public, whereas other content may require authentication for non-owner users, |
| 68 | if they can access the inbox at all.")) |
| 69 | |
| 70 | (define-public outbox |
| 71 | (build-as-property |
| 72 | "outbox" as:Object as:OrderedCollection |
| 73 | #:comment |
| 74 | "The outbox stream contains activities the user has published, subject to |
| 75 | the ability of the requestor to retrieve the activity (that is, the contents of |
| 76 | the outbox are filtered by the permissions of the person reading it). If a |
| 77 | user submits a request without Authorization the server should respond with all |
| 78 | of the Public posts. This could potentially be all relevant objects published |
| 79 | by the user, though the number of available items is left to the discretion of |
| 80 | those implementing and deploying the server.")) |
| 81 | |
| 82 | (define-public following |
| 83 | (build-as-property |
| 84 | "following" as:Object as:Collection |
| 85 | #:comment |
| 86 | "This is a list of everybody that the actor has followed, added as a side |
| 87 | effect. The following collection MUST be either an OrderedCollection or a |
| 88 | Collection and MAY be filtered on privileges of an authenticated user or as |
| 89 | appropriate when no authentication is given.")) |
| 90 | |
| 91 | (define-public followers |
| 92 | (build-as-property |
| 93 | "followers" as:Object as:Collection |
| 94 | #:comment |
| 95 | "This is a list of everyone who has sent a Follow activity for the actor, |
| 96 | added as a side effect. This is where one would find a list of all the actors |
| 97 | that are following the actor. The followers collection MUST be either an |
| 98 | OrderedCollection or a Collection and MAY be filtered on privileges of an |
| 99 | authenticated user or as appropriate when no authentication is given.")) |
| 100 | |
| 101 | (define-public liked |
| 102 | (build-as-property |
| 103 | "liked" as:Object as:Collection |
| 104 | #:comment |
| 105 | "This is a list of every object from all of the actor's Like activities, |
| 106 | added as a side effect. The liked collection MUST be either an OrderedCollection |
| 107 | or a Collection and MAY be filtered on privileges of an authenticated user or |
| 108 | as appropriate when no authentication is given.")) |
| 109 | |
| 110 | (define-public streams |
| 111 | (build-as-property |
| 112 | "streams" as:Object as:Collection |
| 113 | #:comment |
| 114 | "A list of supplementary Collections which may be of interest.")) |
| 115 | |
| 116 | (define-public preferredUsername |
| 117 | (build-as-property |
| 118 | "preferredUsername" as:Object string? |
| 119 | #:comment |
| 120 | "A short username which may be used to refer to the actor, with no |
| 121 | uniqueness guarantees.")) |
| 122 | |
| 123 | (define-public endpoints |
| 124 | (build-as-property |
| 125 | "endpoints" as:Object json-object? |
| 126 | #:comment |
| 127 | "A json object which maps additional (typically server/domain-wide) |
| 128 | endpoints which may be useful either for this actor or someone referencing this |
| 129 | actor. This mapping may be nested inside the actor document as the value or |
| 130 | may be a link to a JSON-LD document with these properties.")) |
| 131 | |
| 132 | (define-public proxyUrl |
| 133 | (build-as-property |
| 134 | "proxyUrl" endpoints uri? |
| 135 | #:comment |
| 136 | "Endpoint URI so this actor's clients may access remote ActivityStreams |
| 137 | objects which require authentication to access. To use this endpoint, the |
| 138 | client posts an x-www-form-urlencoded id parameter with the value being the id |
| 139 | of the requested ActivityStreams object.")) |
| 140 | |
| 141 | (define-public oauthAuthorizationEndpoint |
| 142 | (build-as-property |
| 143 | "oauthAuthorizationEndpoint" endpoints uri? |
| 144 | #:comment |
| 145 | "If OAuth 2.0 bearer tokens are being used for authenticating client to |
| 146 | server interactions, this endpoint specifies a URI at which a |
| 147 | browser-authenticated user may obtain a new authorization grant.")) |
| 148 | |
| 149 | (define-public oauthTokenEndpoint |
| 150 | (build-as-property |
| 151 | "oauthTokenEndpoint" endpoints uri? |
| 152 | #:comment |
| 153 | "If OAuth 2.0 bearer tokens are being used for authenticating client to |
| 154 | server interactions, this endpoint specifies a URI at which a client may |
| 155 | acquire an access token.")) |
| 156 | |
| 157 | (define-public provideClientKey |
| 158 | (build-as-property |
| 159 | "provideClientKey" endpoints uri? |
| 160 | #:comment |
| 161 | "If Linked Data Signatures and HTTP Signatures are being used for |
| 162 | authentication and authorization, this endpoint specifies a URI at which |
| 163 | browser-authenticated users may authorize a client's public key for client to |
| 164 | server interactions.")) |
| 165 | |
| 166 | (define-public signClientKey |
| 167 | (build-as-property |
| 168 | "signClientKey" endpoints uri? |
| 169 | #:comment |
| 170 | "If Linked Data Signatures and HTTP Signatures are being used for |
| 171 | authentication and authorization, this endpoint specifies a URI at which a |
| 172 | client key may be signed by the actor's key for a time window to act on behalf |
| 173 | of the actor in interacting with foreign servers.")) |
| 174 | |
| 175 | (define-public sharedInbox |
| 176 | (build-as-property |
| 177 | "sharedInbox" endpoints uri? |
| 178 | #:comment |
| 179 | "An optional endpoint used for wide delivery of publicly addressed |
| 180 | activities and activities sent to followers. sharedInbox endpoints SHOULD also |
| 181 | be publicly readable OrderedCollection objects containing objects addressed to |
| 182 | the Public special collection. Reading from the sharedInbox endpoint MUST NOT |
| 183 | present objects which are not addressed to the Public endpoint.")) |
| 184 | |
| 185 | (define activitypub-ontology |
| 186 | (merge-ontologies as:activitystreams-ontology |
| 187 | (make-ontology |
| 188 | '() |
| 189 | '() |
| 190 | (list source content mediaType inbox outbox following |
| 191 | followers liked streams preferredUsername |
| 192 | endpoints proxyUrl oauthAuthorizationEndpoint |
| 193 | oauthTokenEndpoint provideClientKey signClientKey |
| 194 | sharedInbox)))) |
| 195 |