An OpenBadges image baking library that works with PNGs and SVGs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin Fix oven bin. Nov 6, 2013
lib Strip scripts from svgs Apr 24, 2017
test Expose type checker Nov 26, 2013
.gitignore Starting openbadges-bakery Sep 18, 2012
.jshintrc Fix lint errors [ci skip] Sep 19, 2012
.npmignore Starting openbadges-bakery Sep 18, 2012
.travis.yml Updated travis ci config May 3, 2017
LICENSE-MPL-2.0
Makefile Whitespace Nov 5, 2013
README.md
index.js Add `getAssertion` alias to match docs. Jun 20, 2014
package.json Updated travis ci config May 3, 2017

README.md

openbadges-bakery Build Status

An OpenBadges image baking library that works with PNGs and SVGs

Install

$ npm install openbadges-bakery

CLI Usage

Baking

$ oven [--in ./path/to/image.svg] [--out ./path/to/baked-image.svg] <data>

If --out is not set, the baked image will print to stdout.

The input file can also be piped into stdin.

$ oven <data> <  ./path/to/image.png  > ./path/to/baked-image.png

Extracting

$ oven [--in path/to/image.png] --extract

Same as above, you can also pipe a file to stdin. The data will be printed to stdout.

Libary Usage

bakery.bake(options callback);

Bakes some data into an image.

Options are

  • image: either a buffer or a stream representing the PNG or SVG to bake
  • assertion: assertion to save into the image (optional)
  • signature: JSON Web Signature representing a signed OpenBadges assertion (optional)

You must pass either assertion or signature

callback has the signature function(err, imageData)

bakery.extract(image, callback)

Gets the raw data from the badge. This could be a URL, assertion in JSON format or a signature.

callback has the signature function (err, data)

bakery.debake(image, callback);

bakery.getAssertion(image, callback);

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.

image should be a stream or a buffer

callback has the signature function (err, object) where object is expected to be a OpenBadges assertion.