Token JavaScript SDK
Below describes SDK v2 beta, for v1, see here.
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 = ;const Token = env: 'sandbox';
Browser:
;const Token = env: 'sandbox';
If not using as a module, then include it as a 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.