Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

›Users API

Users API

  • Users.getUsage() method
  • Users.setupMailbox() method
  • Users.getMailboxID() method
  • Users.sendMessage() method
  • Users.watchInbox() method
  • Users.watchSentbox() method
  • Users.listSentboxMessages() method
  • Users.deleteSentboxMessage() method
  • Users.listInboxMessages() method
  • Users.readInboxMessage() method
  • Users.deleteInboxMessage() method
  • Users.listThreads() method
  • Users.getThread() method
  • Users.copyAuth() method
  • Users.withUserAuth() method
  • Users.withKeyInfo() method
  • Users.getToken() method
  • Users.getTokenChallenge() method
  • Users.setToken() method
  • Users.withThread() method

Types

  • GetThreadResponse interface
  • InboxListOptions interface
  • MailboxEvent interface
  • MailboxEventType enum
  • PushPathResult interface
  • PushPathsResult interface
  • SentboxListOptions interface
  • UserMessage interface
  • UsageOptions interface
  • GetUsageResponse interface

Identity interfaces

  • Identity interface
  • Identity.public property
  • Identity.sign() method
  • Private interface
  • Public interface
  • Public.bytes property
  • Public.verify() method

Private Key Class

  • PrivateKey class
  • PrivateKey.bytes property
  • PrivateKey.canSign() method
  • PrivateKey.decrypt() method
  • PrivateKey.fromRandom() method
  • PrivateKey.fromString() method
  • PrivateKey.privKey property
  • PrivateKey.pubKey property
  • PrivateKey.public property
  • PrivateKey.sign() method
  • PrivateKey.seed property
  • PrivateKey.toString() method
  • PrivateKey.type property
  • PrivateKey.fromRawEd25519Seed() method

Public Key Class

  • PublicKey class
  • PublicKey.fromString() method
  • PublicKey.toString() method
  • PublicKey.verify() method
  • PublicKey.encrypt() method
  • PublicKey.bytes property
  • PublicKey.type property
  • PublicKey.pubKey property

@textile/hub > Users > sendMessage

Users.sendMessage() method

A local user can author messages to remote user through their public-key

Signature:

sendMessage(from: Identity, to: Public, body: Uint8Array): Promise<UserMessage>;

Parameters

ParameterTypeDescription
fromIdentitydefines the local, sending, user. Any object that conforms to the Identity interface.
toPublicdefines the remote, receiving user. Any object that conforms to the Public interface.
bodyUint8Arrayis the message body bytes in UInt8Array format.

Returns:

Promise<UserMessage>

Example

import { Users, Identity, PublicKey  } from "@textile/hub"

async function example(users: Users, from: Identity, to: PublicKey, message: string) {
  const encoder = new TextEncoder()
  const body = encoder.encode(message)
  return await users.sendMessage(from, to, body)
}

← Users.getMailboxID() methodUsers.watchInbox() method →
  • Users.sendMessage() method
  • Parameters
  • Example
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio