Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

›Getting Started

Getting Started

  • Introduction
  • Package Overview

Users API

  • Users class

Buckets

  • Buckets class

Threads

  • Client class

Common Methods & Classes

  • ThreadID class
  • createUserAuth() function
  • createAPISig() function

@textile/hub

hub package

A web-gRPC wrapper client for communicating with the web-gRPC enabled Textile ThreadDB & Buckets APIs.

Classes

ClassDescription
BucketsBuckets a client wrapper for interacting with the Textile Buckets API.
ClientClient is a web-gRPC wrapper client for communicating with a webgRPC-enabled Threads server. This client library can be used to interact with a local or remote Textile gRPC-service It is a wrapper around Textile Thread's 'DB' API, which is defined here: https://github.com/textileio/go-threads/blob/master/api/pb/threads.proto.
FilecoinFilecoin is a client wrapper for interacting with the Textile Hub Filecoin API.
PrivateKeyDefault implementation of the Private interface, with decryption support. In theory, RSA, ed25519, and secp256k1 key types (and more) should be supported, although currently only ed25519 has full sign and decrypt capabilities.
PublicKeyDefault implementation of the Public interface, with encryption support. In theory, RSA, ed25519, and secp256k1 key types (and more) should be supported, although currently only ed25519 has full verify and encrypt capabilities.
QueryQuery allows to build queries to be used to fetch data from a model.
ReadTransactionReadTransaction performs a read-only bulk transaction on the underlying store.
ThreadIDThreadID represents a self-describing Thread identifier.It is formed by a Version, a Variant, and a random number of a given length.
ThreadKeyKey is a thread encryption key with two components.
UsersUsers a client wrapper for interacting with the Textile Users API.This API has the ability to:- Register new users with a User Group key and obtain a new API Token- Get and List all Threads created for/by the user in your app.- Create an inbox for the user or send message to another user's inbox.- Check, read, and delete messages in a user's inbox.
WriteTransactionWriteTransaction performs a mutating bulk transaction on the underlying store.

Enumerations

EnumerationDescription
Action
ArchiveStatusArchive job status codes
JobStatusStorage job status codes
MailboxEventTypeThe mailbox event type. CREATE, SAVE, or DELETE
PathAccessRole
StatusThe status query filter of an inbox message.
VariantVariant denotes Thread variant. Currently only two variants are supported.

Functions

FunctionDescription
bytesToArray(chunk, size)bytesToArray converts a buffer into <4mb chunks for use with grpc API
createAPISig(secret, date)createAPISig generates an authorization signature and message only.This function should NOT be used client-side, as it requires a key secret.
createUserAuth(key, secret, date, token)Generate a UserAuth containing API key, signature, and message.The gRPC APIs will throw (or return an authorization error) if the message date has passed. This function should NOT be used client-side, as it requires a key secret. The result does not contain the secret and therefor CAN be used client side.
decrypt(ciphertext, privKey, type)Decrypts the given data using a Curve25519 variant of the private key.Assumes ciphertext includes ephemeral public key and nonce used in original encryption (e.g., via encrypt() function).
encrypt(data, pubKey, type)Encrypts the given data using a Curve25519 variant of the public key.The encryption uses an ephemeral private key, which is prepended to the ciphertext, along with a nonce of random bytes.
extractPublicKeyBytes(key)Utility function to extract the raw bytes from a Public key.
listPathFlat(grpc, bucketKey, path, dirs, depth)listPathFlat returns a string array of all paths in a bucket
listPathRecursive(grpc, bucketKey, path, depth, currentDepth)listPathRecursive returns a nested object of all paths (and info) in a bucket
privateKeyBytesToString(bytes)Encode the given privateKey's protobuf-encoded bytes to its base-32 encoded multibase representation.
privateKeyFromString(str)Decode the given base-32 encoded multibase string into a Private key.
privateKeyToString(key)Encode the given PrivateKey to its base-32 encoded multibase representation.
publicKeyBytesFromString(str)Decode the given base-32 encoded multibase string into a Public key.
publicKeyBytesToString(bytes)Encode the given PublicKey's protobuf-encoded bytes to its base-32 encoded multibase representation.
publicKeyToString(key)Encode the given PublicKey to its base-32 encoded multibase representation.

Interfaces

InterfaceDescription
AddressInfoInformation about a wallet address.
ArchiveInformation about a bucket archive.
ArchiveConfigArchiveConfig is the desired state of a Cid in the Filecoin network.
ArchiveDealInfoInformation about a Filecoin deal for a bucket archive.
ArchiveOptionsAn object to configure options for Archive.
ArchiveRenewArchiveRenew contains renew configuration for a ArchiveConfig.
ArchivesCurrent and past archives for a bucket.
BuckMetadata
CidInfoInformation about the current jobs and storage state of a data cid.
CidSummarySummary information about a cid in Powergate.
ColdConfigCold storage configuration.
ColdInfoCurrent cold storage state.
CollectionConfigCollectionConfig is the configuration options for creating and updating a Collection. It supports the following configuration options: - Name: The name of the collection, e.g, "Animals" (must be unique per DB). - Schema: A JSON Schema), which is used for instance validation. - Indexes: An optional list of index configurations, which define how instances are indexed. - WriteValidator: An optional JavaScript (ECMAScript 5.1) function that is used to validate instances on write. - ReadFilter: An optional JavaScript (ECMAScript 5.1) function that is used to filter instances on read.The writeValidator function receives three arguments: - writer: The multibase-encoded public key identity of the writer. - event: An object describing the update event (see core.Event). - instance: The current instance as a JavaScript object before the update event is applied.A falsy return value indicates a failed validation. Note that the function arguments must be named as documented here (writer, event, instance). These functions run in a secure sandbox where these argument names are specified.Having access to writer, event, and instance opens the door to a variety of app-specific logic. Textile Buckets file-level access roles are implemented in part with a write validator.The readFilter function receives three arguments: - reader: The multibase-encoded public key identity of the reader. - instance: The current instance as a JavaScript object.The function must return a JavaScript object. Most implementations will modify and return the current instance. Note that the function arguments must be named as documented here (reader, instance). These functions run in a secure sandbox where these argument names are specified. Like write validation, read filtering opens the door to a variety of app-specific logic. Textile Buckets file-level access roles are implemented in part with a read filter.
CopyAuthOptionsSet additional options when copying authentication.
CreateOptions
CreateResponseBucket create response
CriterionJSONCriterionJSON represents a single Query criteria.
CustomerResponseThe response type from getUsage
CustomerUsage
DBInfoDBInfo contains joining/sharing information for a Thread/DB.
DealErrorInformation about a deal error.
DealRecordsConfigA configuration object to control the behavior of querying for deal records.
FilConfigFilecoin storage configuration.
FilInfoCurrent Filecoin storage state.
FilRenewFilecoin storage renew configuration.
FilStorageCurrent Filecoin storage state with a single miner.
FilterFilter parameters for db subscription
GetOrCreateOptionsOptions for getOrCreate
GetOrCreateResponseResponse from getOrCreate
GetThreadResponse
GetUsageResponse
HotConfigHot storage configuration.
HotInfoCurrent hot storage state.
IdentityIdentity represents an entity capable of signing a message. This is a simple "private key" interface that must be capable of returning the associated "public key" for verification. In many cases, the Identity will just be a private key, but callers can use any setup that suits their needs. The interface is currently modeled after libp2p-crypto keys. It is meant to be implemented by external libraries, though in practice, implementations are provided by the @textile/crypto library.If using in your own application, see the PrivateKey class.
InboxListOptionsInbox query options
IpfsConfigIPFS related storage configuration.
IpfsHotInfoCurrent IPFS storage state.
LinksResponse from bucket links query.
MailboxEventThe event type returned from inbox and sentbox subscriptions
PathA bucket list path response
PathItemA bucket path item response
Period
PrivatePrivate is an alias for the Identity interface.
PublicPublic is any entity associated with a given Identity that is capable of verifying a signature produced by said identity. In most cases, a public key will be obtained as a property of an object implementing the Identity and/or Private key interface.
PushOptionsPushOptions provides additional options for controlling a push to a bucket path.
PushPathResultThe expected result format from pushing a path to a bucket
PushPathsResultThe expected result format from pushing multiple paths to a bucket
QueryJSONQueryJSON represents a single store Query.
RemovePathOptionsRemovePathOptions provides additional options for path remove steps.
RemovePathResponseResponse from remote path.
RetrievalDealInfoInformation about a retrieval deal.
RetrievalDealRecordA record of a single retrieval deal.
RootBucket root info
SentboxListOptionsSentbox query options
SortJSONSortJSON describes how and what field on which to sort a query.
StorageConfigConfiguration for storing data in Powergate.
StorageDealInfoInformation about a Filecoin storage deal.
StorageDealRecordA record of a single storage deal.
StorageInfoCurrent data storage state.
StorageJobInformation about a storage job.
Update
Usage
UsageOptionsGetUsage options
UserMessageThe message format returned from inbox or sentbox
ValueJSONJSONValue is used by the gRPC server to handle JSON data types.
WithKeyInfoOptionsSet the options for authenticating with an API key
WithUserAuthOptionsSet the options for authenticating with a user auth

Variables

VariableDescription
AbortError
errors
keyFromStringkeyFromString returns a key by decoding a base32-encoded string.
keyToStringString returns the base32-encoded string representation of raw key bytes.
MailConfigGlobal settings for mailboxes
randomBytes
WhereAlias Criterion to Where for a slightly nicer API (see example below)

Type Aliases

Type AliasDescription
APISigCreate an API signature for use in authenticated systems. Generate with createAPISig().
CreateObject
GetThreadResponseObj
KeyInfoKeyInfo is a type that contains the API Secret. It should never be shared in insecure environments.
LinksObject
MetadataObject
PathItemObject
PathObject
RootObject
UserAuthUserAuth is a type describing the minimal requirements create a session from a user group key. Generate with createUserAuth().Optional token generated by Client.getToken or Client.getTokenChallenge.
← IntroductionUsers class →
  • hub package
  • Classes
  • Enumerations
  • Functions
  • Interfaces
  • Variables
  • Type Aliases
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio