Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonld-signatures

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonld-signatures - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

10

Gruntfile.js

@@ -42,10 +42,8 @@ /*

// grunt istanbul
grunt.loadNpmTasks('grunt-istanbul');
grunt.config('exec', {
});
// grunt release
grunt.loadNpmTasks('grunt-release');
grunt.config('release', {
options: {
commitMessage: 'Release version <%= version %> to npmjs.org.'
}});

@@ -52,0 +50,0 @@ // _jshint

2

package.json
{
"name": "jsonld-signatures",
"version": "0.0.2",
"version": "0.0.3",
"description": "An implementation of the Linked Data Signatures specification for JSON-LD in node.js.",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/digitalbazaar/jsonld-signatures",

@@ -8,3 +8,3 @@ jsonld-signatures

An implementation of the Linked Data Signatures specification for JSON-LD.
An implementation of the Linked Data Signatures specification for JSON-LD.
This software works in all modern browsers as well as node.js.

@@ -18,26 +18,72 @@

```js
var signedDoc = {
"name": "Manu Sporny",
"url": "http://manu.sporny.org/",
"image": "http://manu.sporny.org/images/manu.png"
"signature": {
}
// 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': jsigs.SECURITY_CONTEXT_URL,
'@id': 'https://example.com/i/alice/keys/1',
owner: 'https://example.com/i/alice',
publicKeyPem: testPublicKeyPem
};
// verify a signed JSON-LD document
jsigs.verify(signedDoc, function(err, verified) {
// should print 'Signed document verified: true' to the console
console.log('Signed document verified:', verified);
});
// specify the public key owner object
var testPublicKeyOwner = {
"@context": jsigs.SECURITY_CONTEXT_URL,
'@id': 'https://example.com/i/alice',
publicKey: [testPublicKey]
};
// verify a signed JSON-LD document at a particular URL
jsigs.verify('http://example.org/signedDoc',...);
// 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'
};
// use the promises API
var promises = jsigs.promises;
// sign the document and then verify the signed document
jsigs.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
jsigs.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 promise = promises.verify(signedDoc);
promise.then(function(verified) {...}, function(err) {...});
var sign = jsigs.promises.sign(testDocument, {
privateKeyPem: testPrivateKeyPem,
creator: 'https://example.com/i/alice/keys/1'
});
sign.then(function(signedDocument) {...}, function(err) {...});
var verify = jsigs.promises.verify(signedDocument, {
publicKey: testPublicKey,
publicKeyOwner: testPublicKeyOwner
});
verify.then(function(verified) {...}, function(err) {...});
```

@@ -72,3 +118,3 @@

make test
npm run test

@@ -78,13 +124,10 @@ The standard tests will run node and browser tests. Just one type can also

make test-node
make test-browser
npm run test-node
npm run test-browser
Code coverage of node tests can be generated in `coverage/`:
make test-coverage
npm run coverage
The Mocha output reporter can be changed to min, dot, list, nyan, etc:
make test REPORTER=dot
[jsonld-signatures]: https://github.com/digitalbazaar/jsonld-signatures/
[jsonld-signatures]: https://github.com/digitalbazaar/jsonld-signatures/
[key-example]: https://github.com/digitalbazaar/jsonld-signatures/blob/44f1f67db2cfb0b166b7d5f63c40e10cc4642416/tests/test.js#L73
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc