@oasisprotocol/client

An oasis-core SDK for TypeScript

Users of this package, see this getting started guide.

Philosophy

Prioritize exposing an unopinionated binding to oasis-node's gRPC services. Mostly leave the protocol and formats be, and don't create too much abstraction over it. Aim to create a library that will take less work to maintain when oasis-core changes. The target audience is developers who are already familiar with oasis-core.

Inventory of what's here

  1. A layer over grpc-web to hook up CBOR-based message serialization.
  2. Method definitions and wrappers to represent the node's gRPC methods.
  3. A heuristic to convert structures from CBOR maps to JavaScript objects.
  4. Type definitions for structures.
  5. Helpers for operating on a few kinds of data.
  6. Constants.
  7. JSDoc copied from Godoc.
  8. Wrappers for consensus transactions.

Design notes

  1. There is no conversion layer between deserialized messages and further object model.
  2. Non-structure types, e.g. specialized byte arrays such as Quantity and PublicKey don't have dedicated names in the type system.
  3. Types are only interfaces (where possible), and helpers are standalone functions.

Caveats

  1. oasis-node's gRPC interface is not desigend to be secure against untrusted clients. We suggest using this SDK with an additional access control component.
  2. Native gRPC is not accessible over the web. The grpc-web project suggests setting up an Envoy proxy to allow browsers to connect.
  3. Empty structures are deserialized into an empty Map, due to a limitation in the heuristic that converts structures to objets.
  4. Go prefers to use nil instead of some empty values and to serialize them as null or missing structure fields. This behavior is not modeled in this library's type system.