Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
openbadges-validator
Advanced tools
$ npm install openbadges-validator
The following documentation assumes the module has been imported like so:
var validator = require('openbadges-validator');
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"
.
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
.
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.)
assertion
(object)Returns one of "1.1.0"
, "1.0.0"
, "0.5.0"
, or false
if no version recognized.
Returns true
if the signature can be decoded and looks like a badge.
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.
FAQs
openbadges validation tools
The npm package openbadges-validator receives a total of 0 weekly downloads. As such, openbadges-validator popularity was classified as not popular.
We found that openbadges-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.