Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (38 sloc) 1.775 kb
eb221bb @brianloveswords Fix readme [ci skip]
brianloveswords authored
1 # openbadges-bakery [![Build Status](https://secure.travis-ci.org/mozilla/openbadges-bakery.png)](http://travis-ci.org/mozilla/openbadges-bakery)
f659cb1 @brianloveswords Modify package.json; add travis
brianloveswords authored
2
66b9d6f @brianloveswords Update readme
brianloveswords authored
3 An OpenBadges image baking library that works with PNGs and SVGs
4
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
5 # Install
6 ```bash
7 $ npm install openbadges-bakery
8 ```
9 # CLI Usage
10
11 ## Baking
12
13 ```bash
66b9d6f @brianloveswords Update readme
brianloveswords authored
14 $ oven [--in ./path/to/image.svg] [--out ./path/to/baked-image.svg] <data>
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
15 ```
16 If `--out` is not set, the baked image will print to stdout.
17
18 The input file can also be piped into stdin.
4c7b86d @brianloveswords Add a little more to the readme [ci skip]
brianloveswords authored
19
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
20 ```bash
2af6e89 @brianloveswords Fix some issuers with bin/oven.
brianloveswords authored
21 $ oven <data> < ./path/to/image.png > ./path/to/baked-image.png
4c7b86d @brianloveswords Add a little more to the readme [ci skip]
brianloveswords authored
22 ```
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
23 ## Extracting
24
25 ```bash
26 $ oven [--in path/to/image.png] --extract
27 ```
28
29 Same as above, you can also pipe a file to stdin. The data will be printed to stdout.
30
31 # Libary Usage
32
33 ## bakery.bake(options callback);
34
35 Bakes some data into an image.
36
37 Options are
66b9d6f @brianloveswords Update readme
brianloveswords authored
38 - `image`: either a buffer or a stream representing the PNG or SVG to bake
f959dc1 @brianloveswords Implement signed badge baking.
brianloveswords authored
39 - `assertion`: assertion to save into the image (optional)
40 - `signature`: JSON Web Signature representing a signed OpenBadges assertion (optional)
41
42 You must pass either `assertion` or `signature`
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
43
44 `callback` has the signature `function(err, imageData)`
45
66b9d6f @brianloveswords Update readme
brianloveswords authored
46 ## bakery.extract(image, callback)
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
47
f959dc1 @brianloveswords Implement signed badge baking.
brianloveswords authored
48 Gets the raw data from the badge. This could be a URL, assertion in JSON format or a signature.
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
49
66b9d6f @brianloveswords Update readme
brianloveswords authored
50 `callback` has the signature `function (err, data)`
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
51
66b9d6f @brianloveswords Update readme
brianloveswords authored
52 ## bakery.debake(image, callback);
f959dc1 @brianloveswords Implement signed badge baking.
brianloveswords authored
53 ## bakery.getAssertion(image, callback);
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
54
f959dc1 @brianloveswords Implement signed badge baking.
brianloveswords authored
55 Gets the assertion from the badge. If the assertion is remote, this will require an HTTP request. If the assertion is baked into the badge, either directly or as part of a signature, this will pull the local copy.
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
56
66b9d6f @brianloveswords Update readme
brianloveswords authored
57 `image` should be a stream or a buffer
0b43aee @brianloveswords Add `bin/oven`, update readme, change function name.
brianloveswords authored
58
66b9d6f @brianloveswords Update readme
brianloveswords authored
59 `callback` has the signature `function (err, object)` where `object` is expected to be a OpenBadges assertion.
Something went wrong with that request. Please try again.