RemoteStorage.WireClient

WireClient Interface

This file exposes a get/put/delete interface on top of XMLHttpRequest.  It requires to be configured with parameters about the remotestorage server to connect to.  Each instance of WireClient is always associated with a single remotestorage server and access token.

Usually the WireClient instance can be accessed via `remoteStorage.remote`.

This is the get/put/delete interface

  • #get() takes a path and optionally a ifNoneMatch option carrying a version string to check.  It returns a promise that will be fulfilled with the HTTP response status, the response body, the MIME type as returned in the ‘Content-Type’ header and the current revision, as returned in the ‘ETag’ header.
  • #put() takes a path, the request body and a content type string.  It also accepts the ifMatch and ifNoneMatch options, that map to the If-Match and If-None-Match headers respectively.  See the remotestorage-01 specification for details on handling these headers.  It returns a promise, fulfilled with the same values as the one for #get().
  • #delete() takes a path and the ifMatch option as well.  It returns a promise fulfilled with the same values as the one for #get().

In addition to this, the WireClient has some compatibility features to work with remotestorage 2012.04 compatible storages.  For example it will cache revisions from folder listings in-memory and return them accordingly as the “revision” parameter in response to #get() requests.  Similarly it will return 404 when it receives an empty folder listing, to mimic remotestorage-01 behavior.  Note that it is not always possible to know the revision beforehand, hence it may be undefined at times (especially for caching-roots).

Summary
RemoteStorage.WireClientWireClient Interface
Events
changeNever fired for some reason # TODO create issue and fix or remove
connectedFired when the wireclient connect method realizes that it is in possession of a token and href
Properties
tokenHolds the bearer token of this WireClient, as obtained in the OAuth dance
hrefHolds the server’s base URL, as obtained in the Webfinger discovery
storageApiHolds the spec version the server claims to be compatible with
Functions
configureSets the userAddress, href, storageApi, token, and properties of a remote store.

Events

change

Never fired for some reason # TODO create issue and fix or remove

connected

Fired when the wireclient connect method realizes that it is in possession of a token and href

Properties

token

Holds the bearer token of this WireClient, as obtained in the OAuth dance

Example

remoteStorage.remote.token
// -> 'DEADBEEF01=='

href

Holds the server’s base URL, as obtained in the Webfinger discovery

Example

remoteStorage.remote.href
// -> 'https://storage.example.com/users/jblogg/'

storageApi

Holds the spec version the server claims to be compatible with

Example

remoteStorage.remote.storageApi
// -> 'draft-dejong-remotestorage-01'

Functions

configure

configure: function (settings)

Sets the userAddress, href, storageApi, token, and properties of a remote store.  Also sets connected and online to true and emits the ‘connected’ event, if both token and href are present.

Parameters

settingsAn object that may contain userAddress (string or null), href (string or null), storageApi (string or null), token (string or null), and/or properties (the JSON-parsed properties object from the user’s WebFinger record, see section 10 of http://tools.ietf.org/html/draft-dejong-remotestorage-03 or null).  Fields that are not included (i.e.  `undefined`), stay at their current value.  To set a field, include that field with a `string` value.  To reset a field, for instance when the user disconnected their storage, or you found that the token you have has expired, simply set that field to `null`.
configure: function (settings)
Sets the userAddress, href, storageApi, token, and properties of a remote store.
Close