This PR ports the existing Server API and some of its extensions, as well as adding a new Path class.
Server
The server API has been ported with one major change: a Peer is now provided alongside the extensions during instantiation. This allows us to get rid of a few extensions like ExtensionKnownShares, the only purpose of which was to configure the Peer. This can now be done prior to the instantiation of the server and in any manner the user wishes.
Server extensions
ExtensionSyncWebsocket has been added, replacing ExtensionSyncWeb. This allows the server to accept incoming requests from Earthstar peers and begin a WGPS sync session over websockets.
ExtensionKnownShares is deprecated by being able to configure Peer ourselves.
Porting ExtensionServeContent and ExtensionServerSettings has been deferred as these need a closer look after Willow has changed the patterns of paths and authorisation, respectively.
Path
Willow defines paths as a sequence of bytestrings, in contrast with Earthstar's paths which were made up of strings with a restricted character set. But if Earthstar is to support features such as encryption, it cannot further restrict Willow's definition of a Path. However, we do not want to lose the accessibility which string-based paths brought to creating and undestanding paths.
The new Path class wraps an underlying Path as defined by Willow: a sequence of bytestrings. However, the Path class offers many methods which allow simpler path creation and viewing than you'd get by interacting with Uint8Array, for example:
Path.fromStrings creates a Path from an array of legible strings containing alphanumeric characters, -, _, or ..
Path.asStrings returns an array of legible strings if it's able to parse them from the underlying Path.
Path.format is able to return a path as a single string with its components encoded as legible strings or base32.
And there are many utility methods such as isPrefixOf, withSuffix etc. Please see the diff for the full range of (documented) methods.
This PR ports the existing
Server
API and some of its extensions, as well as adding a newPath
class.Server
The server API has been ported with one major change: a
Peer
is now provided alongside the extensions during instantiation. This allows us to get rid of a few extensions likeExtensionKnownShares
, the only purpose of which was to configure thePeer
. This can now be done prior to the instantiation of the server and in any manner the user wishes.Server extensions
ExtensionSyncWebsocket
has been added, replacingExtensionSyncWeb
. This allows the server to accept incoming requests from Earthstar peers and begin a WGPS sync session over websockets.ExtensionKnownShares
is deprecated by being able to configurePeer
ourselves.ExtensionServeContent
andExtensionServerSettings
has been deferred as these need a closer look after Willow has changed the patterns of paths and authorisation, respectively.Path
Willow defines paths as a sequence of bytestrings, in contrast with Earthstar's paths which were made up of strings with a restricted character set. But if Earthstar is to support features such as encryption, it cannot further restrict Willow's definition of a Path. However, we do not want to lose the accessibility which string-based paths brought to creating and undestanding paths.
The new
Path
class wraps an underlyingPath
as defined by Willow: a sequence of bytestrings. However, thePath
class offers many methods which allow simpler path creation and viewing than you'd get by interacting withUint8Array
, for example:Path.fromStrings
creates aPath
from an array of legible strings containing alphanumeric characters,-
,_
, or.
.Path.asStrings
returns an array of legible strings if it's able to parse them from the underlying Path.Path.format
is able to return a path as a single string with its components encoded as legible strings or base32.And there are many utility methods such as
isPrefixOf
,withSuffix
etc. Please see the diff for the full range of (documented) methods.