Javascript (Node and Browser) SDK for interacting with the Token System
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
test
.esdoc.json
.eslintignore
.eslintrc.js
.flowconfig
.gitignore
.npmignore
README.md
babel.config.js
package-lock.json
package.json
protogen.js
rollup.config.js

README.md

Token JavaScript SDK

Below describes SDK v2 beta, for v1, see here.

npm version

The JavaScript SDK for interacting with TokenOS.

Installation

If using npm:

npm install token-io

If using yarn:

yarn add token-io

Usage

See SDK docs and API reference.

There are also samples and sample tests in the source code for reference.

Node:

const {TokenIO} = require('token-io');
const Token = new TokenIO({env: 'sandbox'});

Browser:

import {TokenIO} from 'token-io';
const Token = new TokenIO({env: 'sandbox'});

If not using as a module, then include it as a script:

<script src="https://unpkg.com/token-io@^2.0.0-beta/dist/tokenio.iife.min.js"></script>

This will provide you with the TokenIO global object.

Typing

We provide typing support for the API through Flow.

If you choose to integrate Flow into your project, you can use the following command as a type checker:

npm run flow check

Testing

Node:

# targets dev environment by default
npm test

# for other envs (local, dev, stg, sandbox, prd)
ENV=sandbox npm test

Browser:

# targets dev environment and Chrome by default
npm run testBrowser

# for other envs (local, dev, stg, sandbox, prd) or browsers (Chrome, Firefox, Safari, IE, Edge)
ENV=sandbox npm run testBrowser -- --browsers Safari

Building

Make sure you have recent versions of Node and npm.

To install dependencies:

npm install

To build:

npm run build # CommonJS and ES6 distributions for both Node and browser

This SDK uses Babel for transpiling and Rollup for bundling.