mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
Merge pull request #56 from bigchaindb/browser-bundles
Add all browser bundles (for master)
This commit is contained in:
commit
516ed7a031
64
README.md
64
README.md
@ -17,13 +17,14 @@
|
||||
|
||||
## Contents
|
||||
|
||||
* [Installation](#installation)
|
||||
* [Installation and Usage with package managers (npm/yarn)](#installation-and-usage-with-package-managers-npmyarn)
|
||||
* [Example: Create a transaction](#example-create-a-transaction)
|
||||
* [Use a pre-built image (browser only)](#use-a-pre-built-image-browser-only)
|
||||
* [Documentation](#bigchaindb-documentation)
|
||||
* [Authors](#authors)
|
||||
* [License](#license)
|
||||
|
||||
## Installation
|
||||
## Installation and Usage with package managers (npm/yarn)
|
||||
|
||||
```bash
|
||||
npm install bigchaindb-driver
|
||||
@ -74,6 +75,65 @@ conn.postTransaction(txSigned)
|
||||
.then((res) => console.log('Transaction status:', res.status))
|
||||
```
|
||||
|
||||
## Use a pre-built image (browser only)
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>HTML5 boilerplate – all you really need…</title>
|
||||
<!-- Adjust version to your needs -->
|
||||
<script src="https://unpkg.com/bigchaindb-driver@0.1.1/dist/browser/bigchaindb-driver.window.min.js"></script>
|
||||
<script>
|
||||
|
||||
// BigchainDB server instance or IPDB (e.g. https://test.ipdb.io/api/v1/)
|
||||
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||
|
||||
// Create a new user with a public-private key pair
|
||||
// (or a whole bunch of them, nobody's counting)
|
||||
const alice = new BigchainDB.Ed25519Keypair()
|
||||
|
||||
// Construct a transaction payload
|
||||
// `BigchainDB.Transaction.makeCreateTransaction()`: create a new asset
|
||||
// `BigchainDB.Transaction.makeTransferTransaction()`: transfer an existing asset
|
||||
const tx = BigchainDB.Transaction.makeCreateTransaction(
|
||||
{ assetMessage: 'My very own asset...' },
|
||||
{ metaDataMessage: 'wrapped in a transaction' },
|
||||
// A transaction needs an output
|
||||
// `BigchainDB.Transaction.makeOutput()`: requires a crypto-condition
|
||||
// `BigchainDB.Transaction.makeEd25519Condition()`: simple public key output
|
||||
[ BigchainDB.Transaction.makeOutput(
|
||||
BigchainDB.Transaction.makeEd25519Condition(alice.publicKey))
|
||||
],
|
||||
alice.publicKey
|
||||
)
|
||||
|
||||
// Optional: You've got everything you need, except for an asset
|
||||
// and metadata. Maybe define them here, any JSON-serializable object
|
||||
// will do
|
||||
|
||||
// Ok, now that you have a transaction, you need to *sign* it
|
||||
// cause, you know... cryptography and ¯\_(ツ)_/¯
|
||||
|
||||
// Sign/fulfill the transaction with private keys
|
||||
const txSigned = BigchainDB.Transaction.signTransaction(tx, alice.privateKey)
|
||||
|
||||
// Send the transaction off to BigchainDB
|
||||
let conn = new BigchainDB.Connection(API_PATH, { 'Content-Type': 'application/json' })
|
||||
|
||||
conn.postTransaction(txSigned)
|
||||
.then(() => conn.getStatus(txSigned.id))
|
||||
.then((res) => console.log('Transaction status:', res.status))
|
||||
// Check console for the transaction's status
|
||||
</script>
|
||||
</head>
|
||||
<body id="home">
|
||||
<h1>Hello BigchainDB</h1>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## BigchainDB Documentation
|
||||
|
||||
- [HTTP API Reference](https://docs.bigchaindb.com/projects/server/en/latest/http-client-server-api.html)
|
||||
|
@ -11,7 +11,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"author": "BigchainDB",
|
||||
"main": "./dist/node/index.js",
|
||||
"browser": "./dist/browser/bundle.min.js",
|
||||
"browser": "./dist/browser/bigchaindb-driver.cjs2.min.js",
|
||||
"scripts": {
|
||||
"lint": "eslint ./",
|
||||
"build": "npm run clean && npm run build:cjs && npm run build:dist",
|
||||
@ -29,7 +29,9 @@
|
||||
"report-coverage": "nyc report --reporter=lcov > coverage.lcov && codecov"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": ["eslint"]
|
||||
"*.js": [
|
||||
"eslint"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.19.1",
|
||||
|
@ -14,6 +14,39 @@ const PATHS = {
|
||||
NODE_MODULES: path.resolve(__dirname, 'node_modules'),
|
||||
}
|
||||
|
||||
const OUTPUTS = [
|
||||
{
|
||||
filename: PRODUCTION ? 'bigchaindb-driver.window.min.js' : 'bigchaindb-driver.window.js',
|
||||
library: 'BigchainDB',
|
||||
libraryTarget: 'window',
|
||||
path: PATHS.BUNDLE,
|
||||
},
|
||||
{
|
||||
filename: PRODUCTION ? 'bigchaindb-driver.umd.min.js' : 'bigchaindb-driver.umd.js',
|
||||
library: 'bigchaindb-driver',
|
||||
libraryTarget: 'umd',
|
||||
path: PATHS.BUNDLE,
|
||||
},
|
||||
{
|
||||
filename: PRODUCTION ? 'bigchaindb-driver.cjs.min.js' : 'bigchaindb-driver.cjs.js',
|
||||
library: 'bigchaindb-driver',
|
||||
libraryTarget: 'commonjs',
|
||||
path: PATHS.BUNDLE,
|
||||
},
|
||||
{
|
||||
filename: PRODUCTION ? 'bigchaindb-driver.cjs2.min.js' : 'bigchaindb-driver.cjs2.js',
|
||||
library: 'bigchaindb-driver',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: PATHS.BUNDLE,
|
||||
},
|
||||
{
|
||||
filename: PRODUCTION ? 'bigchaindb-driver.amd.min.js' : 'bigchaindb-driver.amd.js',
|
||||
library: 'bigchaindb-driver',
|
||||
libraryTarget: 'amd',
|
||||
path: PATHS.BUNDLE,
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
/** PLUGINS **/
|
||||
const PLUGINS = [
|
||||
@ -40,18 +73,9 @@ if (PRODUCTION) {
|
||||
PLUGINS.push(...PROD_PLUGINS)
|
||||
}
|
||||
|
||||
|
||||
/** EXPORTED WEBPACK CONFIG **/
|
||||
const config = {
|
||||
const configBoilerplate = {
|
||||
entry: [PATHS.ENTRY],
|
||||
|
||||
output: {
|
||||
filename: PRODUCTION ? 'bundle.min.js' : 'bundle.js',
|
||||
library: 'js-bigchaindb-driver',
|
||||
libraryTarget: 'umd',
|
||||
path: PATHS.BUNDLE,
|
||||
},
|
||||
|
||||
devtool: PRODUCTION ? '#source-map' : '#inline-source-map',
|
||||
|
||||
resolve: {
|
||||
@ -77,4 +101,11 @@ const config = {
|
||||
},
|
||||
}
|
||||
|
||||
/** EXPORTED WEBPACK CONFIG **/
|
||||
const config = OUTPUTS.map(output => {
|
||||
const configCopy = Object.assign({}, configBoilerplate)
|
||||
configCopy.output = output
|
||||
return configCopy
|
||||
})
|
||||
|
||||
module.exports = config
|
||||
|
21
yarn.lock
21
yarn.lock
@ -971,8 +971,8 @@ base-x@^3.0.2:
|
||||
safe-buffer "^5.0.1"
|
||||
|
||||
base64-js@^1.0.2:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1"
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
|
||||
|
||||
bcrypt-pbkdf@^1.0.0:
|
||||
version "1.0.1"
|
||||
@ -3573,7 +3573,14 @@ node-fetch@1.5.1:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
node-fetch@^1.0.1, node-fetch@~1.6.0:
|
||||
node-fetch@^1.0.1:
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5"
|
||||
dependencies:
|
||||
encoding "^0.1.11"
|
||||
is-stream "^1.0.1"
|
||||
|
||||
node-fetch@~1.6.0:
|
||||
version "1.6.3"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.6.3.tgz#dc234edd6489982d58e8f0db4f695029abcd8c04"
|
||||
dependencies:
|
||||
@ -4236,8 +4243,8 @@ read@^1.0.7:
|
||||
mute-stream "~0.0.4"
|
||||
|
||||
readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.0.tgz#640f5dcda88c91a8dc60787145629170813a1ed2"
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.1.tgz#84e26965bb9e785535ed256e8d38e92c69f09d10"
|
||||
dependencies:
|
||||
core-util-is "~1.0.0"
|
||||
inherits "~2.0.3"
|
||||
@ -4522,8 +4529,8 @@ rxjs@^5.0.0-beta.11:
|
||||
symbol-observable "^1.0.1"
|
||||
|
||||
safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.1.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223"
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
|
||||
|
||||
safe-buffer@~5.0.1:
|
||||
version "5.0.1"
|
||||
|
Loading…
Reference in New Issue
Block a user