npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

openbadges-validator

v1.1.1

Published

openbadges validation tools

Downloads

72

Readme

OpenBadges Validator Tools Build Status

Installing

$ npm install openbadges-validator

Usage

The following documentation assumes the module has been imported like so:

var validator = require('openbadges-validator');

validator(input, callback, version, verificationType)

Validate a badge assertion and return an object containing info about the validated assertion.

  • input (object or string) should be an assertion object, json string representing an assertion object,URL for a hosted assertion, or a signed badge signature.

  • callback (function) A function taking two parameters (err, data), where err == null indicates a valid badge, and data is an object containing all validation data collected before an error was thrown.Take a look at the structure of the full resulting data object.

  • version (string) Optional: force the validator to check against a certain specification version. Allowed values: "0.5.0", "1.0.0" `"1.1.0".

  • verificationType (string) Optional: force the validator to use a certain type of verification. Allowed values: "hosted", "signed".

validator.getAssertionGUID(urlOrSignature, callback)

Given either a hosted assertion URL or a signed assertion, return an alphanumeric string that uniquely identifies the badge.

The callback is passed two arguments, (err, guid).

If the assertion is hosted, guid will be the SHA256 hash of the following string:

hosted: assertion URL

If the assertion is signed, guid will be the SHA256 hash of the following string:

signed: assertion UID : origin of assertion's public key

For example, if the signed assertion's public key is hosted at https://example.org/public-key and the assertion's UID is abcd, then the assertion's GUID will be the hex-encoded SHA256 hash of signed:abcd:https://example.org, or 61ae9c039ecc7d08cac6fea3ed6fa3d47463b34e3f2f3bbe86be33688b2f105a.

validator.doesRecipientMatch(info, identity)

Returns a boolean indicating whether or not an assertion has been issued to a particular recipient.

info is an object containing properties about the assertion, as returned by the validator function.

identity is an email address. (In the future, identities other than email addresses may be supported.)

validator.parseVersion(assertion)

  • assertion (object)

Returns one of "1.1.0", "1.0.0", "0.5.0", or false if no version recognized.

validator.isSignedBadge(signature)

Returns true if the signature can be decoded and looks like a badge.

Tests

By default, this only runs local tests:

npm test

To run all tests (including those that require an internet connection), use:

node node_modules/tap/bin/tap test/*

A code coverage report can be generated with node_modules/.bin/jake test-cov (or jake test-cov if you have jake installed globally) and viewed in cover_html/index.html.

The coverage tool used is node-cover, see its documentation for details.

License

MPL 2.0