Code Monkey home page Code Monkey logo

oasis.js's Introduction

CircleCI Gitter chat docs

See the documentation.

Packages

The Client

For most use cases, it's recommended to use the main @oasislabs/client package for all your Oasis client needs, for which there is extensive documentation.

Package Version Description
@oasislabs/client npm Client SDK for interacting with services on Oasis

Internal Packages

However, if you only need a subset of the client's features, you can take what you need directly from the underlying packages. Together these packages compose the client. Standalone documentation is not provided so it's recommended to use these only if you know what you're doing.

Package Version Description
@oasislabs/gateway npm Oasis Gateway implementation used as the client backend
@oasislabs/service npm Connects to and deploys IDL defined services
@oasislabs/confidential npm Primitives for confidentiality
@oasislabs/common npm Common utilities for Oasis packages
@oasislabs/test npm Tools used in Oasis tests
@oasislabs/web3 npm Web3 JSON RPC version of an Oasis Gateway

Contributing

Installing

To get started first install the required build tools:

npm install -g lerna
npm install -g yarn

Then bootstrap the workspace:

yarn

Building

To build the workspace:

yarn build

In each package, the built javascript and typescript definitions will be in dist/. For direct browser testing of a client, simply include the rollup artifact directly in your script tag, e.g., <script src=/dist/index.umd.js></script>. For example here.

Testing

To run all tests:

yarn test

Linting

To lint:

yarn lint

To apply lint fixes:

yarn lint:fix

Publishing new npm package versions

This is a multi-package repo; packages are managed by lerna.

First, bump the version number in all package.json:

git checkout -b mybranch
lerna version  # bumps package numbers and creates a commit

Get the PR approved and merge it. Then pull the newly-updated master and push packages from it to npm:

git checkout master && git pull
lerna publish from-package

oasis.js's People

Contributors

armaniferrante avatar eauge avatar ennsharma avatar lukaw3d avatar mitjat avatar nhynes avatar peterjgilbert avatar pro-wh avatar ravenac95 avatar ryscheng-bot[bot] avatar suquark avatar vishwa-raman avatar willscott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oasis.js's Issues

Generate UUID for session key

After discussion, @eauge and I decided that the client should generate a session key for the user and include that in its requests to the developer gateway.

TODO:

  • Generate UUID upon creation
  • Include the UUID in the header of each request to the developer gateway
  • Define how to prevents clients from accessing other client's sessions

RPC input validation

Given I'm a developer,
When I call an Oasis Service rpc method with an invalid input,
Then I should receive a useful error.

Potential test cases:

  
  it('throws an exception when the incorrect type is given to an rpc', async () => {
    // Given.
    let service = new Service(idl);

    // When.
    let input1 = defType();
    let input2 = 'hi';
    let promise = service.rpc.the(input1, input2);

    // Then.
    return expect(promise).rejects.toEqual(
      new Error(`Invalid arguments ${JSON.stringify([input1, input2])}`)
    );
  });

  • Validate RPC arguments
  • Validate deploy arguments

Web3 backend

We should implement and support a web3 backend for the client so that it can talk directly to web3 gateways.

TODO:

  • New implementation of the OasisGateway interface.
  • Propagate service options to the gateway backend, i.e., add an optional "options" parameter to all service rpcs.

Build & Release End Client

TODO:

  • rpcs + http protocol to dev-server #3
  • get public key #37
  • update idl #26
  • generate sighash from idl #15
  • oasis-gateway deploy #42
  • integration tests #31
  • subscribe #38
  • confidential data wire format #50 < 1 day
  • UUID session #51 ~3 days +- 2 (blocked)
  • docs #29 ~ 2 days
  • web3 backend #52 ~ 5 days
  • license #92 < 1 day
  • 'X-OASIS-INSECURE-AUTH': 'example' #90 ~1 day
  • developer gateway needs a timeout policy #82 ~1 day
  • #109
  • decode responses #57 ~ 1 day (blocked)
  • rpc serialization #85 (blocked)
  • update readme links #68 < 1 day
  • publish on npm #88 < 1 day
  • confidential flows
  • e2e tests in CI oasislabs/e2e-tests#93
  • deploy build to cdn #158
  • replace mantle references with new name #156
  • yarn lock security alerts #154

NPM Publish

Because we need an issue for everything ;)

HTTP Web3Gateway

We can do invoke with http now that we have an endpoint in the oasis_namespace.

Don't add a deploy header when using an EthereumGateway

Currently, we will add a deploy header with confidential set to true when using an ethereum gateway. This doesn't make sense for the new runtime,.

Instead, we should use default Ethereum semantics. To do this, we probably want to move the prepending of the deploy header to the initcode to be within the RpcCoder interface so that we can just ignore the header from the EthereumGateway and use it from an OasisGateway.

Add new confidential data wire format

Proposed format: public key || cipher length || aad length || cipher || aad || nonce || signature

Cipher length and AAD length are both encoded u64 to keep the cipher 16 byte aligned.

Uniform node and browser module imports with rollup

Currently, we have some utility modules that dispatch based based upon whether we're in a browser environment or not. We should be able to remove these by configuring Rollup to import the modules correctly.

For example, we we import tweetnacl like this with this file.

Also our EventEmitter imports need fixing (e.g., see #25), as they are causing us to use any types.

Don't discover confidentiality via getPublicKey

Currently we "discover" confidentiality by querying getPublicKey.

With the new key manager, this is no longer acceptable because all contracts have keys. Instead, we'll have to check the deploy header via inspecting the code.

developer-gateway: Don't poll forever

Currently the client just polls the developer-gateway forever until it gets the response back.

We should have a policy for when to give up and throw an error.

Implement a provider to make network requests

Implement HTTP and WS versions of something like

export interface Provider {
  // Data in the transaction field.
  send(request: RpcRequest): Promise<any>;
  subscribe(request: SubscribeRequest): EventEmitter;
}

Should probably have invoke semantics.

  • RPCs
  • Subscriptions

Configureable default properties on oasis object

For example, to point to a custom network, all Service's must be instantiated with a gateway pointing at a desired network, e.g., new oasis.Service(idl, address, { gateway}). Similarly, for key storage.

If no such options are specified, default ones are used here.

It would be nice if clients could override default options with a custom set, so that instantiating (and deploying) new Services used such default options. This would dry up code with repeated instantiations/deployments of different services, so that the above code turns into new oasis.Service(idl, address).

Oasis Client Documentation TODOs

  • p1: update docs depending upon marketing names
  • p1: update docs after publishing to CDN
  • p1: document http headers for dev gateway (i.e. for the change here: de69353)

Staging authentication mechanism

We need mechanisms to authenticate the user. One mechanism that we have is google auth. However, to make testing easy, and be able to have multiple users, we have 'X-OASIS-INSECURE-AUTH': 'example', so that we can have multiple users providing a different value so that their sessions will not collide.

In the case of NilAuth, which is another auth that @willscott added, collisions are avoided by making sure that sessions are always different. For the developer gateway though, all users will be the same user when using NilAuth.

In my opinion we may need to define an authentication mechanism that we can use at least for staging to make our lives easier, which still provides authentication but not tied to google oauth.

Originally posted by @eauge in #90 (comment)

Rename repo to oasis.js

oasisclient is unidiomatic. oasis-client isn't descriptive enough since there is, in fact, a rust client.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.