Class: IndirectKeystoreInteraction

interaction.IndirectKeystoreInteraction()

Base class for indirect keystore interactions.

Subclasses must implement two methods: request and parse. Application code will pass the result of calling request to some external process (HTTP request, QR code, &c.) and pass the response to parse which should return a result.

Constructor

new IndirectKeystoreInteraction()

Sets the this.indirect property to true. This property can be utilized when introspecting on interaction classes.

The this.workflow property is an array containing one or both of the strings request and/or parse. Their presence and order indicates to calling applications whether they are necessary and in which order they should be run.

Source:
Example
import {IndirectKeystoreInteraction} from "unchained-wallets";
class SimpleIndirectInteraction extends IndirectKeystoreInteraction {   *

  constructor({param}) {
    super();
    this.param = param;
  }

  request() {
    // Construct the data to be passed to the keystore...
    return this.param;
  }

  parse(response) {
    // Parse data returned from the keystore...
    return response;
  }

}

const interaction = new SimpleIndirectInteraction({param: "foo"});

const request = interaction.request();
const response = "bar"; // Or do something complicated with `request`
const result = interaction.parse(response);
console.log(result);
// "bar"

Methods

parse(response) → {Object}

Parse the response into a result.

Subclasses must override this function. It must accept an appropriate kind of response object and return the final result of this interaction.

Parameters:
Name Type Description
response Object

the raw response

Source:
Returns:

the parsed response

Type
Object

request() → {Object}

Provide the request.

Subclasses may override this function. It can return any kind of object. Strings, data for QR codes, HTTP requests, command lines, functions, &c. are all allowed. Whatever is appropriate for the interaction.

Source:
Returns:

the request data

Type
Object

(async) run() → {void}

Throws an error.

Source:
Throws:

An error since this is an indirect interaction.

Returns:
Type
void