2.1.1 • Published 3 years ago

bc-vault-js v2.1.1

Weekly downloads
216
License
MIT
Repository
github
Last release
3 years ago

bc-js

Javascript library for interfacing with the BC VAULT daemon via HTTP.

Description

BC-JS is a clientside library which makes integrating support for BC VAULT as easy as possible. When reading this documentation keep in mind that some functions that require user input will display a popup to the user for confirmation. No extra work is required on your part but keep that in mind.

All functions are defined as Promises, which means that in supported environments you can use the native await syntax to resolve actions.

Documentation

A static version of the latest documentation is hosted at https://www.bc-vault.com/api/js/ You can also build the documentation yourself using the instructions below

Quick start in browser

To get started download bc-js and place it somewhere where it can be found from a HTML file. This will register the object _bcvault in the global window object. This object is a union of all other Global types and an instance of BCJS. This means you can do const a = _bcvault.WalletType.bitCoin and const b = _bcvault.getDevices(), you can also create a new object of type BCJS using const c = new _bcvault.BCJS()

Include it where needed:

<head>
<script src="/path/to/bc-js.js"></script>
</head>

For example, to query currently connected devices:

<head>
	<script src="/path/to/bc-js.js"></script>
</head>
<body>
  <script>
    window.addEventListener("load",function(){
		_bcvault.getDevices().then(function(resultArray){
            console.log(resultArray);
        });
    }
  </script>
</body>

or, if your target browsers support async/await:

<head>
	<script src="/path/to/bc-js.js"></script>
</head>
<body>
  <script>
    window.addEventListener("load",async function(){
        var result = await _bcvault.getDevices();
        console.log(result);
    }
  </script>
</body>

Quick start in Node.js

To get started, run npm i bc-vault-js or yarn add bc-vault-js

A simple example - querying the current device list:

const bclib = require("bc-vault-js")

let bc = new bclib.BCJS(()=>{});// first arg MUST be a function in node, see AuthWindowHandler to find out more

bc.getDevices().then((result)=>{
  console.log(JSON.stringify(result));
})

//this should output [1,2,3,4,5] depending on how many BC Vaults are connected.

IE workarounds

To support Internet Explorer which doesn't allow communication cross-domain-area between popups, we had to use showModalDialog internally. This means that if a popup is shown in IE, it will block the entire browser until it is either completed or closed. Other browsers are unaffected.

Build Instructions

Generate Documentation

Global Dependencies

  • TypeDoc

Instructions

  1. Make sure to cd to the project root
  2. Run npm run doc

Alternatively, run typedoc directly:

typedoc --mode file --excludeNotExported --excludePrivate --name bc-js --out docs

Output

Output files are in docs/

Build

Global Dependencies

  1. Typescript
  2. Browserify

Instructions

  1. Make sure to cd to the project root
  2. Run npm run build

Output

Output files are in

  • build/es5 - ES5 Polyfills for IE, used in bc_js_ie.js
  • build/es2017 - ES2017 with commonJS modules (NodeJS)
  • build/es6 - ES6 with commonJS modules (NodeJS), also used in bc_js_noie.js
  • build/esnext - ES6 with esnext modules (Future)
  • build/bc_js_*.js - Browserified single dependency output for use in browsers.
2.1.1

3 years ago

2.1.0

3 years ago

2.0.5

3 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.3

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.29

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago