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
connectedfired when the wireclient connect method realizes that it is in posession of a token and a 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

Events

change

never fired for some reason

connected

fired when the wireclient connect method realizes that it is in posession of a token and a 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'
Close