diff --git a/src/common/common.types.ts b/src/common/common.types.ts index 8fdfae4..abaac84 100644 --- a/src/common/common.types.ts +++ b/src/common/common.types.ts @@ -129,4 +129,20 @@ export type StartIndexValue = number; export type SourceValue = { content: ContentValue, mediaType?: MediaType, -} \ No newline at end of file +} +export type InboxValue = string | OrderedCollection | Link; +export type OutboxValue = string | OrderedCollection | Link; +export type FollowingValue = string | Collection | OrderedCollection | Link; +export type FollowersValue = string | Collection | OrderedCollection | Link; +export type LikedValue = string | Collection | OrderedCollection | Link; +export type LikesValue = string | Collection | OrderedCollection | Link; +export type SharesValue = string | Collection | OrderedCollection | Link; +export type StreamsValue = string | Collection | OrderedCollection | Link; +export type PreferredUsernameValue = string; +export type PreferredUsernameMapValue = Record; +export type ProxyUrlValue = string; +export type OauthAuthorizationEndpointValue = string; +export type OauthTokenEndpointValue = string; +export type ProvideClientKeyValue = string; +export type SignClientKeyValue = string; +export type SharedInboxValue = string; \ No newline at end of file diff --git a/src/models/actor/Actor.types.ts b/src/models/actor/Actor.types.ts index 1075005..ac3c35e 100644 --- a/src/models/actor/Actor.types.ts +++ b/src/models/actor/Actor.types.ts @@ -1,27 +1,177 @@ import {APObjectFields} from "../apObject/APObject.types"; +import { + FollowersValue, + FollowingValue, + InboxValue, + LikedValue, + OauthAuthorizationEndpointValue, + OauthTokenEndpointValue, + OutboxValue, + PreferredUsernameMapValue, + PreferredUsernameValue, + ProvideClientKeyValue, + ProxyUrlValue, SharedInboxValue, + SignClientKeyValue, + StreamsValue +} from "../../common/common.types"; -// TODO edit -type Endpoints = { - proxyUrl?: any; - oauthAuthorizationEndpoint?: any; - oauthTokenEndpoint?: any; - provideClientKey?: any; - signClientKey?: any; - sharedInbox?: any; +export interface EndpointsValue { + + /** + * Endpoint URI so this actor's clients may access remote ActivityStreams + * objects which require authentication to access. To use this endpoint, + * the client posts an x-www-form-urlencoded id parameter with the value + * being the id of the requested ActivityStreams object. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + proxyUrl?: ProxyUrlValue; + + /** + * If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating + * client to server interactions, this endpoint specifies a URI at which a + * browser-authenticated user may obtain a new authorization grant. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + oauthAuthorizationEndpoint?: OauthAuthorizationEndpointValue; + + /** + * If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating + * client to server interactions, this endpoint specifies a URI at which a client + * may acquire an access token. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + oauthTokenEndpoint?: OauthTokenEndpointValue; + + /** + * If Linked Data Signatures and HTTP Signatures are being used for authentication + * and authorization, this endpoint specifies a URI at which browser-authenticated + * users may authorize a client's public key for client to server interactions. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + provideClientKey?: ProvideClientKeyValue; + + /** + * If Linked Data Signatures and HTTP Signatures are being used for authentication an + * authorization, this endpoint specifies a URI at which a client key may be signed + * by the actor's key for a time window to act on behalf of the actor in interacting + * with foreign servers. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + signClientKey?: SignClientKeyValue; + + /** + * An optional endpoint used for wide delivery of publicly addressed activities and + * activities sent to followers. sharedInbox endpoints SHOULD also be publicly readable + * OrderedCollection objects containing objects addressed to the Public special collection. + * Reading from the sharedInbox endpoint MUST NOT present objects which are not addressed + * to the Public endpoint. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + sharedInbox?: SharedInboxValue; } export interface ActorFields extends APObjectFields { - inbox: any; - outbox: any; - following?: any; - followers?: any; - liked?: any; - streams?: any; + + /** + * The inbox is discovered through the inbox property of an actor's profile. + * The inbox MUST be an OrderedCollection. The inbox stream contains all activities + * received by the actor. The server SHOULD filter content according to the + * requester permission. In general, the owner of an inbox is likely to be + * able to access all of their inbox contents. Depending on access control, + * some other content may be public, whereas other content may require + * authentication for non-owner users, if they can access the inbox at all. + * + * {@link https://www.w3.org/TR/activitypub/#inbox Docs} + */ + inbox: InboxValue; + + /** + * The outbox is discovered through the outbox property of an actor's profile. + * The outbox MUST be an OrderedCollection. The outbox stream contains activities + * the user has published, subject to the ability of the requester to retrieve the + * activity (that is, the contents of the outbox are filtered by the permissions + * of the person reading it). If a user submits a request without Authorization the + * server should respond with all the Public posts. This could potentially be all + * relevant objects published by the user, though the number of available items is + * left to the discretion of those implementing and deploying the server. + * + * {@link https://www.w3.org/TR/activitypub/#outbox Docs} + */ + outbox: OutboxValue; + + /** + * Every actor SHOULD have a collection of following. This is a list of everybody that + * the actor has followed, added as a side effect. The following collection MUST be + * either an OrderedCollection or a Collection and MAY be filtered on privileges of an + * authenticated user or as appropriate when no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#following Docs} + */ + following?: FollowingValue; + + /** + * Every actor SHOULD have a collection of followers. This is a list of everyone who has + * sent a Follow activity for the actor, added as a side effect. This is where one would + * find a list of all the actors that are following the actor. The followers collection + * MUST be either an OrderedCollection or a Collection and MAY be filtered on privileges + * of an authenticated user or as appropriate when no authentication is given. + * + * NOTE: The follow activity generally is a request to see the objects an actor creates. + * This makes the Followers collection an appropriate default target for delivery of notifications. + * + * {@link https://www.w3.org/TR/activitypub/#followers Docs} + */ + followers?: FollowersValue; + + /** + * Every actor MAY have a liked collection. This is a list of every object from all the + * actor's Like activities, added as a side effect. The liked collection MUST be either + * an OrderedCollection or a Collection and MAY be filtered on privileges of an + * authenticated user or as appropriate when no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#liked Docs} + */ + liked?: LikedValue; + + /** + * A list of supplementary Collections which may be of interest. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + streams?: StreamsValue | StreamsValue[]; // TODO preferredUsername or preferredUsernameMap at one time - preferredUsername?: any; - preferredUsernameMap?: any; - endpoints?: any; + /** + * A short username which may be used to refer to the actor, with no uniqueness guarantees. + * [For multiple language-tagged values use preferredUsernameMap property] + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + preferredUsername?: PreferredUsernameValue; + + /** + * A short username which may be used to refer to the actor, with no uniqueness guarantees. + * [For a single value use preferredUsername property] + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + preferredUsernameMap?: PreferredUsernameMapValue; + + /** + * A json object which maps additional (typically server/domain-wide) endpoints which may + * be useful either for this actor or someone referencing this actor. This mapping may be + * nested inside the actor document as the value or may be a link to a JSON-LD document with + * these properties. + * + * {@link https://www.w3.org/TR/activitypub/#actors Docs} + */ + endpoints?: EndpointsValue; } diff --git a/src/models/apObject/APObject.types.ts b/src/models/apObject/APObject.types.ts index 49c6745..5fbdb75 100644 --- a/src/models/apObject/APObject.types.ts +++ b/src/models/apObject/APObject.types.ts @@ -28,7 +28,7 @@ import { SummaryValue, SummaryMapValue, UpdatedValue, - DurationValue, SourceValue, + DurationValue, SourceValue, LikesValue, SharesValue, } from "../../common/common.types"; export interface APObjectFields { @@ -87,7 +87,7 @@ export interface APObjectFields { * The content or textual representation of the Object encoded as a JSON string. * By default, the value of content is HTML. The mediaType property can be * used in the object to indicate a different content type. - * [For multiple language-tagged values use contentMap property]. + * [For multiple language-tagged values use contentMap property] * * {@link https://www.w3.org/ns/activitystreams#content Docs} */ @@ -97,7 +97,7 @@ export interface APObjectFields { * The content or textual representation of the Object encoded as a JSON string. * By default, the value of content is HTML. The mediaType property can be * used in the object to indicate a different content type. - * [For a single value use content property]. + * [For a single value use content property] * * {@link https://www.w3.org/ns/activitystreams#content Docs} */ @@ -341,4 +341,24 @@ export interface APObjectFields { * {@link https://www.w3.org/TR/activitypub/#source-property Docs} */ source?: SourceValue; + + /** + * Every object MAY have a "likes" collection. This is a list of all Like activities with this object as + * the object property, added as a side effect. The likes collection MUST be either an OrderedCollection + * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when + * no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#likes Docs} + */ + likes?: LikesValue; + + /** + * Every object MAY have a "shares" collection. This is a list of all Announce activities with this object as + * the object property, added as a side effect. The shares collection MUST be either an OrderedCollection + * or a Collection and MAY be filtered on privileges of an authenticated user or as appropriate when + * no authentication is given. + * + * {@link https://www.w3.org/TR/activitypub/#shares Docs} + */ + shares?: SharesValue; } \ No newline at end of file