Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
jsonld-signatures
Advanced tools
An implementation of the Linked Data Signatures specifications for JSON-LD in JavaScript.
An implementation of the Linked Data Signatures specification for JSON-LD. This software works in all modern browsers as well as node.js via npm.
Install with npm:
npm install jsonld-signatures
In Node.js, include the library like this:
var jsonld = require('jsonld');
var jsig = require('jsonld-signatures');
jsig.use('jsonld', jsonld);
In a browser environment, include jsonld
, forge
, and
dist/jsonld-signatures.min.js
via script tag or other mechanism.
// to generate the next two lines, run the following command:
//
// openssl genrsa -out key.pem; cat key.pem; openssl rsa -in key.pem -pubout -out pubkey.pem; cat pubkey.pem; rm key.pem pubkey.pem
//
// for an example of how to specify these keys, look at [key-example]:
var testPublicKeyPem = "-----BEGIN PUBLIC KEY-----\r\n...";
var testPrivateKeyPem = "-----BEGIN PRIVATE KEY-----\r\n...";
// specify the public key object
var testPublicKey = {
'@context': jsig.SECURITY_CONTEXT_URL,
'@id': 'https://example.com/i/alice/keys/1',
owner: 'https://example.com/i/alice',
publicKeyPem: testPublicKeyPem
};
// specify the public key owner object
var testPublicKeyOwner = {
"@context": jsig.SECURITY_CONTEXT_URL,
'@id': 'https://example.com/i/alice',
publicKey: [testPublicKey]
};
// create the JSON-LD document that should be signed
var testDocument = {
"@context": {
schema: 'http://schema.org/',
name: 'schema:name',
homepage: 'schema:url',
image: 'schema:image'
},
name: 'Manu Sporny',
homepage: 'https://manu.sporny.org/',
image: 'https://manu.sporny.org/images/manu.png'
};
// sign the document and then verify the signed document
jsig.sign(testDocument, {
privateKeyPem: testPrivateKeyPem,
creator: 'https://example.com/i/alice/keys/1'
}, function(err, signedDocument) {
if(err) {
return console.log('Signing error:', err);
}
console.log('Signed document:', signedDocument);
// verify the signed document
jsig.verify(signedDocument, {
publicKey: testPublicKey,
publicKeyOwner: testPublicKeyOwner,
}, function(err, verified) {
if(err) {
return console.log('Signature verification error:', err);
}
console.log('Signature is valid:', verified);
});
});
// verification
var sign = jsig.promises.sign(testDocument, {
privateKeyPem: testPrivateKeyPem,
creator: 'https://example.com/i/alice/keys/1'
});
sign.then(function(signedDocument) {...}, function(err) {...});
var verify = jsig.promises.verify(signedDocument, {
publicKey: testPublicKey,
publicKeyOwner: testPublicKeyOwner
});
verify.then(function(verified) {...}, function(err) {...});
Commercial support for this library is available upon request from Digital Bazaar: support@digitalbazaar.com
The source code for the JavaScript implementation of the JSON-LD Signatures API is available at:
https://github.com/digitalbazaar/jsonld-signatures
This library includes a sample testing utility which may be used to verify that changes to the processor maintain the correct output.
To run the sample tests you will need to get the test suite files by cloning the jsonld-signatures repository hosted on GitHub.
https://github.com/digitalbazaar/jsonld-signatures/
Run the Node.js tests using the following command:
npm run test
Run browser tests using PhantomJS using the following command:
npm run test-karma
Run browser tests using a selection of browsers using the following command:
npm run test-karma -- --browsers Firefox,Chrome,PhantomJS
Code coverage of node tests can be generated in coverage/
:
npm run coverage
2.3.1 - 2018-09-05
LinkedDataSignature
createVerifyData
to remove
one round of compaction and one round of expansion. This
eliminates a total of four rounds (2x compaction, 2x expansion)
for sign+verify processes as createVerifyData
is used
in both sign
and verify
.FAQs
An implementation of the Linked Data Signatures specifications for JSON-LD in JavaScript.
The npm package jsonld-signatures receives a total of 12,142 weekly downloads. As such, jsonld-signatures popularity was classified as popular.
We found that jsonld-signatures demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.