0.1.12 • Published 7 years ago

ethereum-web-token v0.1.12

Weekly downloads
3
License
MIT
Repository
github
Last release
7 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

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago