0.1.12 • Published 9 years ago

ethereum-web-token v0.1.12

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

Etherem Web Token

EWT bundles Ethereum function-calls into JWT-like tokens. It simplifies the use of ECDSA signatures for webapps and the development of Smart Oracles.

Installation

Install the package with npm i -S ethereum-web-token from the npm registry ethereum-web-token

Usage

Create and Sign a Token

import EWT from 'ethethereum-web-token';

let ABI = [{
  type: 'function', name: 'test',
  inputs: [{ type: 'bool' }, { type: 'string' }]
}];
let priv = '...';

new EWT(ABI).test(true, 'string').sign(priv);

=> 'aaaaaa.bbbbbb.cccccc'

Signed Token Example

eyJ0eXBlIjoiRVdUIiwiYWxnIjoiRVMyNTZrIn0.eyJ0ZXN0IjpbeyJib29sIjp0cnVlfSx7InN0cmluZyI6ImpvaGJhIn1dfQ.Xm0gkO3-jeAxsLU35g60hALU3CrIYQRFnyGv5vbdCDRlB1yABF8Qu8B9pjbIDwh7hfI_d_O5aQoZNib7WqOeLA

encodes

{
  header: { type: 'EWT', alg: 'ES256k' },
  payload: { test: [ { bool: true }, { string: 'johba' } ] },
  sig: {
    v: 27,
    r: '5e6d2090edfe8de031b0b537e60eb48402d4dc2ac86104459f21afe6f6dd0834',
    s: '65075c80045f10bbc07da636c80f087b85f23f77f3b9690a193626fb5aa39e2c'
  }
}

Parse a Token

import EWT from 'ethethereum-web-token';

EWT.parse('aaaaaa.bbbbbb.cccccc');

=> {
  values: [true, 'string'],
  signer: '...' //should match address of priv
}
0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago