This object contains information that the underlying implementation can
use to authenticate a particular actor.
This object is required of all Graffiti methods
that modify objects or media and is optional for methods that read objects.
At a minimum the session object must contain the
actor URI 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 people 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.
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.
This object contains information that the underlying implementation can use to authenticate a particular
actor. This object is required of all Graffiti methods that modify objects or media and is optional for methods that read objects.At a minimum the
sessionobject must contain theactorURI to authenticate with. However it is likely that thesessionobject must contain other implementation-specific properties. For example, a Solid implementation might include afetchfunction. A distributed implementation may include a cryptographic signature.As to why the
sessionobject 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 people who are not logged in with Graffiti.get and Graffiti.discover but without type-checking thesessionit can be easy to forget to hide buttons that trigger other methods that require login.Passing the
sessionobject per-method also allows for multiple sessions to be used within the same application, like an Email client fetching from multiple accounts.