Skip to main content
Module

x/earthstar/mod.ts

A specification and Javascript library for building online tools you can truly call your own.
Go to Latest
import * as earthstar from "https://deno.land/x/earthstar@v9.3.3/mod.ts";

Classes

A pub won't accept writes

Generic top-level error class that other Earthstar errors inherit from.

A pub URL is bad or the network is down

Holds many shares' replicas and manages their synchronisation with other peers. Recommended as the point of contact between your application and Earthstar shares.

Subscribe to the ongoing results of a query, optionally including old existing docs.

A QueryFollower was used after close() was called on it.

A replica of a share's data, used to read, write, and synchronise data to. Should be closed using the close method when no longer being used.

A cached, synchronous interface to a replica, useful for reactive abstractions. Always returns results from its cache, and proxies the query to the backing replica in case of a cache miss.

An IReplica or IReplicaDriver was used after close() was called on it.

A replica driver which perists to LocalStorage, which stores a maximum of five megabytes per domain. If you're storing multiple shares, this limit will be divided among all their replicas. Works in browsers and Deno.

An in-memory replica driver. Its contents will be lost when it is closed. Works everywhere.

A strorage driver which persists to SQLite. Works in Deno and browsers.

An IReplica or IReplicaDriver was used after close() was called on it.

A generic syncer which can be used with any kind of Transport.

Validation failed on a document, share address, author address, etc.

Variables

Lowercase alphabetical characters.

Uppercase alphabetical characters.

All characters allowed in an identity's public address.

All characters allowed in an identity's pub key.

All characters allowed in an identity's short name.

All characters allowed in base32.

Higher-level crypto functions. Not used directly for the most part, but useful for generating new keypairs.

A verison of the ILowLevelCrypto interface backed by noble/ed25519. Works in the browser.

All digits.

Validator for the 'es.4' format. Checks if documents are spec-compliant before ingesting, and signs them according to spec.

All characters permitted in a document's path.

All special characters permitted in a document's path.

All characters allowed in a share's address.

All charaters allowed in a share's key.

All characters allowed in a share's name.

Functions

Put a short name and pub key together into an identity address.

Put a share name and encoded pub key together into a share address.

Encode uint8array bytes to base32 string

Decode base32 string to a uint8array of bytes. Throw a ValidationError if the string is bad.

Check that an identity address is valid.

Check that a share address is valid.

example usage: myArrayOfArrays.sort(arrayCompare)

Convert an AuthorKeypair back into a raw KeypairBytes for use in crypto operations.

Return whether a document is expired or not

Combine a shortname with a raw KeypairBytes to make an AuthorKeypair

Check if any value is a subclass of EarthstarError (return true) or not (return false)

Check that a string contains only printable ASCII

Check if any value is a subclass of EarthstarError (return false) or not (return true)

Check that a string only contains character from a string of allowed characters.

Parse an author address into its parts.

Parse a workspace address into its parts.

Set the crypto driver used for all cryptographic operations.

Returns a promise which is fulfilled after a given number of milliseconds.

Syncs an earthstar replica with a directory on the filesystem, representing Earthstar documents as files and vice versa. Make sure you understand the changes this function could enact upon a given directory before using it, as it can delete files in certain circumstances.

  • Changes from the filesystem which are superseded by writes from the replica will still be synced to the replica as an older version of the document, provided they were authored by different identities.
  • If a document has a certain extension (e.g. .jpg, .mp3), the syncer assumes the contents are base64 encoded when writing data to the filesystem.
  • If a file has a path containing a ! (i.e. an ephemeral path), it will be deleted unless a correspending document is found in the replica.

Interfaces

An identity used to sign documents.

Contains data written and signed by an identity.

A partial doc that is about to get written. The rest of the properties will be computed automatically.

Higher-level crypto functions. Not used directly for the most part, but useful for generating new keypairs.

A crypto driver provides low-level access to an implementation providing ed25519 cryptography, e.g. Chloride, noble/ed25519, Node crypto.

Validators are each responsible for one document format such as "es.4". They are used by Storage instances to check if documents are valid before accepting them and sign new documents.

Holds many shares' replicas and manages their synchronisation with other peers. Recommended as the point of contact between your application and Earthstar shares.

Subscribe to the ongoing results of a query, optionally including old existing docs.

A replica of a share's data, used to read, write, and synchronise data to. Should be closed using the close method when no longer being used.

A replica driver provides low-level access to actual replica and is used by IReplica to actually load and save data. ReplicaDrivers are not meant to be used directly by users; let the Replica talk to it for you.

Describes a query for fetching documents from a replica.

Filters a query by document attributes.

Type Aliases

An identity's public address.

The human-identifiable portion of an identity's public address, e.g. suzy.

  • IngestEventSuccess — a new doc was written
  • IngestEventFailure — refused an invalid doc
  • IngestEventNothingHappened — ingested an obsolete or duplicate doc
  • DocAlreadyExists — processing an old doc as you catch up
  • IdleEvent — reached the end of existing docs; waiting for new docs
  • IngestEvent — the result of a replica ingesting a document
  • ReplicaEventWillClose — the replica is about to close
  • ReplicaEventDidClose — the replica has closed
  • QueryFollowerDidClose — the query follower was closed (can happen on its own or after the replica closes)

The path of a document, e.g. /images/teapot.png.

  • new — not running yet; you need to call "await hatch()".
  • catching-up — hatch() has been called, we're catching up on old docs.
  • live — we're listening for new write events.
  • closed — the query follower is closed.
  • error — an unexpected error happened, maybe in your bus subscription handler.

A share's public address.

The human-identifiable portion of a share's address, e.g. gardening.

A UNIX timestamp in microseconds.