Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

›Buckets

Buckets

  • Buckets.copyAuth() method
  • Buckets.withUserAuth() method
  • Buckets.withKeyInfo() method
  • Buckets.getToken() method
  • Buckets.getTokenChallenge() method
  • Buckets.setToken() method
  • Buckets.withThread() method
  • Buckets.getOrCreate() method
  • Buckets.create() method
  • Buckets.existing() method
  • Buckets.root() method
  • Buckets.links() method
  • Buckets.list() method
  • Buckets.listPath() method
  • Buckets.listPathFlat() method
  • Buckets.listIpfsPath() method
  • Buckets.movePath() method
  • Buckets.open() method
  • Buckets.pushPath() method
  • Buckets.pushPaths() method
  • Buckets.pushPathAccessRoles() method
  • Buckets.pullPath() method
  • Buckets.pullPathAccessRoles() method
  • Buckets.pullIpfsPath() method
  • Buckets.remove() method
  • Buckets.removePath() method
  • Buckets.setPath() method

Experimental

  • Archive interface
  • ArchiveDealInfo interface
  • ArchiveStatus enum

Types

  • GetOrCreateOptions interface
  • GetOrCreateResponse interface
  • CreateOptions interface
  • CreateResponse interface
  • Links interface
  • Path interface
  • PathAccessRole enum
  • PathItem interface
  • Root interface
  • BuckMetadata interface

@textile/hub > Buckets > getTokenChallenge

Buckets.getTokenChallenge() method

Obtain a token for interacting with the remote API. When your app is creating new private-key based users to interact with the API using User Group keys, you must first create a new token for each new user. Tokens do not change after you create them. This callback method will require you to handle challenge signing.

Signature:

getTokenChallenge(publicKey: string, callback: (challenge: Uint8Array) => Uint8Array | Promise<Uint8Array>): Promise<string>;

Parameters

ParameterTypeDescription
publicKeystring
callback(challenge: Uint8Array) => Uint8Array | Promise<Uint8Array>A callback function that takes a challenge argument and returns a signed message using the input challenge and the private key associated with publicKey. publicKey must be the corresponding public key of the private key used in callback.

Returns:

Promise<string>

Example

import { Buckets, PrivateKey } from '@textile/hub'

async function example (buckets: Buckets, identity: PrivateKey) {
  const token = await buckets.getTokenChallenge(
    identity.public.toString(),
    (challenge: Uint8Array) => {
      return new Promise((resolve, reject) => {
        // This is where you should program PrivateKey to respond to challenge
        // Read more here: https://docs.textile.io/tutorials/hub/production-auth/
      })
    }
  )
  return token
}

← Buckets.getToken() methodBuckets.setToken() method →
  • Buckets.getTokenChallenge() method
  • Parameters
  • Example
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio