Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work-in-progress RsaSignature2017 support. #28

Merged
merged 13 commits into from Feb 9, 2018
15 changes: 7 additions & 8 deletions .gitignore
@@ -1,15 +1,14 @@
*.sw[op]
*~
.cproject
.project
*.sublime-project
*.sublime-workspace
*.sw[nop]
*~
.DS_Store
.cproject
.project
.settings
bower_components
TAGS
coverage
dist
node_modules
v8.log
.c9revisions
npm-debug.log
.idea/
v8.log
10 changes: 9 additions & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,15 @@ sudo: false
# download test suite and run tests... submodule? meta testing project with
# all of the reference implementations?
script:
- npm run test-all
- if [ "x$BUNDLER" = "x" ]; then npm run test; fi
- if [ "x$BUNDLER" != "x" ]; then npm run test-karma; fi
# only run karma tests for one node version
matrix:
include:
- node_js: "6"
env: BUNDLER=webpack
# - node_js: "6"
# env: BUNDLER=browserify
notifications:
email:
on_success: change
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,17 @@
# jsonld-signatures ChangeLog

### Changed
- Add webpack support. Build and distribute bundles in `dist` directory.
- Add node6 support. Use babel to generate files in `dist/node6` directory.
Used automatically at runtime.
- Use karma for browser testing.
- Use node and karma test setup files that use a common test file.

### Removed
- **BREAKING**: Removed bower support. Use npm and the bundles in the `dist`
directory.
- Remove grunt support in favor of package.json script targets.

## 1.2.1 - 2017-04-14

### Changed
Expand Down
73 changes: 0 additions & 73 deletions Gruntfile.js

This file was deleted.

30 changes: 18 additions & 12 deletions README.md
Expand Up @@ -11,20 +11,24 @@ This software works in all modern browsers as well as node.js via [npm](https://
Introduction
------------

In node.js, include the library like this:
Install with npm:

```
npm install jsonld-signatures
```

In Node.js, include the library like this:
```js
var jsonld = require('jsonld');
var jsig = require('jsonld-signatures');
jsig.use('jsonld', jsonld);
```

In a browser environment, include the library like this:
In a browser environment, include `jsonld`, `forge`, and
`dist/jsonld-signatures.min.js` via script tag or other mechanism.

You will need to bower install jsonld-signatures and then serve it and
its dependencies from your server and include each via a script tag, or other
mechanism, in the order: es6-promise, async, jsonld, forge, jsonld-signatures.

Here are some examples on using the library:
Examples
--------

```js
// to generate the next two lines, run the following command:
Expand Down Expand Up @@ -124,15 +128,17 @@ the [jsonld-signatures repository][jsonld-signatures] hosted on GitHub.

https://github.com/digitalbazaar/jsonld-signatures/

Run the tests using the following command:
Run the Node.js tests using the following command:

npm run test

The standard tests will run node and browser tests. Just one type can also
be run:
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-node
npm run test-browser
npm run test-karma -- --browsers Firefox,Chrome,PhantomJS

Code coverage of node tests can be generated in `coverage/`:

Expand Down
32 changes: 0 additions & 32 deletions bower.json

This file was deleted.

154 changes: 154 additions & 0 deletions karma.conf.js
@@ -0,0 +1,154 @@
/**
* Karam configuration for jsonld-signatures.
*
* @author Dave Longley
* @author David I. Lehn
*
* Copyright (c) 2011-2017 Digital Bazaar, Inc. All rights reserved.
*/
const path = require('path');
const webpack = require('webpack');

module.exports = function(config) {
// bundler to test: webpack, browserify
var bundler = process.env.BUNDLER || 'webpack';

var frameworks = ['mocha'];
// main bundle preprocessors
var preprocessors = ['babel'];

if(bundler === 'browserify') {
frameworks.push(bundler);
preprocessors.push(bundler);
} else if(bundler === 'webpack') {
preprocessors.push(bundler);
preprocessors.push('sourcemap');
} else {
throw Error('Unknown bundler');
}

config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: frameworks,

// list of files / patterns to load in the browser
files: [
{
pattern: 'tests/test-karma.js',
watched: false, served: true, included: true
}
],

// list of files to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
//'tests/*.js': ['webpack', 'babel'] //preprocessors
'tests/*.js': preprocessors
},

webpack: {
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.js$/,
include: [{
// exclude node_modules by default
exclude: /(node_modules)/
}, {
// include rdf-canonize
include: /(node_modules\/jsonld)/,
include: /(node_modules\/rdf-canonize)/
}],
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},
node: {
Buffer: false,
process: false,
crypto: false,
setImmediate: false
}
},

browserify: {
debug: true
//transform: ['uglifyify']
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
//reporters: ['progress'],
reporters: ['mocha'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['PhantomJS', 'Chrome', 'Firefox', 'Safari'],
browsers: ['PhantomJS'],

customLaunchers: {
IE9: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE9'
},
IE8: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE8'
}
},

phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma
// exits without killing phantom)
exitOnResourceError: true
},

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,

// Mocha
client: {
mocha: {
// increase from default 2s
timeout: 10000,
reporter: 'html'
//delay: true
}
},

// Proxied paths
proxies: {}
});
};