Space SDK Package

Space SDK Package

  • Users
  • Storage
  • Space Docs

›Users API

Getting Started

  • Default Implementations

Users API

  • Users class
  • SpaceUser interface

Storage API

  • UserStorage class
  • IdentityStorage interface
  • BrowserStorage class
  • FileStorage class

@spacehq/sdk > Users

Users class

Users a client wrapper for interacting with the Textile Users API.

This API has the ability to:

  • Create new identity

  • Authenticate via identity against ws challenge

Signature:

export declare class Users 

Example 1

Initialize Users without identity storage

import { Users } from '@spacehq/users'

const users = new Users({ endpoint: "users.space.storage" });

// create new key pair
const id = users.createIdentity();

// authenticate against ws challenge, obtaining storageAuth
const user = await users.authenticate(id);

Example 2

Initialize Users with BrowserStorage

import { Users, BrowserStorage } from '@spacehq/users'

const storage = new BrowserStorage();
// error is thrown when identity fails to auth
const onErrorCallback = (err, identity) => { ... };

// users are automatically restored from stored identities
const users = await Users.withStorage(storage, { endpoint: "users.space.storage" }, onErrorCallback);


Constructors

ConstructorModifiersDescription
(constructor)(config, storage)Constructs a new instance of the Users class

Methods

MethodModifiersDescription
authenticate(identity)Authenticates the random keypair identity against the hub. Generating an appToken API Session token.If authentication succeeds, a SpaceUser object that can be used with the UserStorage class is returned.
backupKeysByPassphrase(uuid, passphrase, backupType, identity)Backup the existing users identity key information using the passphrase provided.Identity can be gotten from SpaceUser gotten after a successful authentication or recovery.
createIdentity()createIdentity generates a random keypair identity.
list()List all in memory SpaceUser that have been authenticated so far.
recoverKeysByPassphrase(uuid, passphrase, backupType)Recovers users identity key information using the passphrase provided.If successfully recovered, the users information is stored in the IdentityStorage (if provided) when initializing the users class.
remove(publicKey)Removes the users identity from list of authenticated users.It also removes the identity from the IdentityStorage provided.
withStorage(storage, config, onError)staticCreates a users
← Default ImplementationsSpaceUser interface →
  • Users class
  • Example 1
  • Example 2
  • Constructors
  • Methods
Space SDK Package
Docs
Getting StartedUsersStorage
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @spacestorage