Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebAccount

Can be used client-side to interact with the BitClout identity service. This is

Hierarchy

Index

Constructors

constructor

  • Construct a bitclout identity that can sign transactions using the BitClout identity service embedded in an iframe. You must first authenticate the user using WebAccount.loginUser, then pass the public key and account added to this constructor.

    Parameters

    • bitcloutPublicKey: string

      The public key of the user.

    • authData: BitcloutAuthData

      The identity service payload object for the user

    • iframe: HTMLIFrameElement

      The iframe element of the embedded identity service

    Returns WebAccount

Properties

Readonly bitcloutPublicKey

bitcloutPublicKey: string

Public key shown on account's bitclout profile

Readonly canSign

canSign: true = true

Methods

logoutUser

  • logoutUser(): void
  • Sign user out (opens another window). Instance will no longer work after calling this.

    Returns void

postMessage

  • postMessage(msg: Record<string, any>): void
  • Posts a message to the identity service iframe. Learn more.

    Parameters

    • msg: Record<string, any>

      The message (in JSON format). Must contain an id if a response is expected (see WebAccount.waitForResponse)

    Returns void

signJWT

  • signJWT(): Promise<any>
  • Sends a request to the embedded identity service for a signed JWT. Throws a SigningError if the response doesn't contain a JWT.

    Returns Promise<any>

    A JWT signed with the user's private key, which can be used to authenticate them to the backend.

signTransaction

  • signTransaction(transactionHex: string, skipApproval?: boolean): Promise<any>
  • First, sends a request to the embedded iframe containing the account data and unsugned transaction hex, then waits for a response. If the response contains a signed hex, it's returned. Otherwise, it opens a new window to ask the user for approval to sign the transaction. If neither method succeeds, it throws a SigningError

    Parameters

    • transactionHex: string

      The unsigned transaction hex

    • Optional skipApproval: boolean

      If true, a SigningError will be thrown immediately without opening an approval window if the initial response doesn't contain a signed transaction

    Returns Promise<any>

    The signed transaction hex

Static loginUser

  • Open a window for the user to login to their BitClout account (learn more).

    Parameters

    • accessLevel: 0 | 2 | 3 | 4 = 2

      Which access level to authorize. Learn more.

    Returns Promise<LoginReturnType>

    An object of authenticated users' credentials. You can pass the returned public key and account data to the constructor.

Static waitForResponse

  • waitForResponse(id?: string): Promise<any>
  • Waits for a message from the identity service, and returns the first one that matches the supplied ID

    Parameters

    • Optional id: string

      The ID sent with the request (or leave empty to return the first message recieved)

    Returns Promise<any>

    The response data

Generated using TypeDoc