Interface GraffitiSession

This object contains information that sources can use to verify that a user has permission to operate a particular actor. This object is required of all Graffiti methods that modify objects and is optional for methods that read objects.

At a minimum the session object must contain the actor URI the user wants to authenticate with. However it is likely that the session object must contain other implementation-specific properties. For example, a Solid implementation might include a fetch function. A distributed implementation may include a cryptographic signature.

As to why the session object is passed as an argument to every method rather than being an internal property of the Graffiti instance, this is primarily for type-checking to catch bugs related to login state. Graffiti applications can expose some functionality to users who are not logged in with Graffiti.get and Graffiti.discover but without type-checking the session it can be easy to forget to hide buttons that trigger other methods that require login. In the future, session object may be updated to include scope information and passing the session to each method can type-check whether the session provides the necessary permissions.

Passing the session object per-method also allows for multiple sessions to be used within the same application, like an Email client fetching from multiple accounts.

interface GraffitiSession {
    actor: string;
    scope?: {};
}

Properties

Properties

actor: string

The actor a user wants to authenticate with.

scope?: {}

A yet undefined property detailing what operations the session grants the user to perform. For example, to allow a user to read private messages from a particular set of channels or to allow the user to write object matching a particular schema.