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

Initial commit (extract from jsonld-signatures). #1

Merged
merged 17 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ['digitalbazaar'],
env: {
node: true
},
ignorePatterns: ['dist/']
};
79 changes: 79 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Node.js CI

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run eslint
run: npm run lint
test-node:
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 10
strategy:
matrix:
node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run test with Node.js ${{ matrix.node-version }}
run: npm run test-node
env:
CI: true
test-karma:
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 10
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Run karma tests
run: npm run test-karma
env:
CI: true
coverage:
needs: [test-node, test-karma]
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Generate coverage report
run: npm run coverage-ci
env:
CI: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage/lcov.info
fail_ci_if_error: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ dist

# TernJS port file
.tern-port

# Editor files
*~
*.sw[nop]
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ed25519-signature-2018 Changelog
# @digitalbazaar/ed25519-signature-2018 Changelog

## 1.0.0 - TBD

### Added
- Initial commit.
- Initial files extracted from https://github.com/digitalbazaar/jsonld-signatures.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Ed25519Signature2018 suite _(@digitalbazaar/ed25519-signature-2018)_

[![Node.js CI](https://github.com/digitalbazaar/ed25519-signature-2018/workflows/Node.js%20CI/badge.svg)](https://github.com/digitalbazaar/ed25519-signature-2018/actions?query=workflow%3A%22Node.js+CI%22)
[![Build status](https://img.shields.io/github/workflow/status/digitalbazaar/ed25519-signature-2018/Node.js%20CI)](https://github.com/digitalbazaar/ed25519-signature-2018/actions?query=workflow%3A%22Node.js+CI%22)
[![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/ed25519-signature-2018)](https://codecov.io/gh/digitalbazaar/ed25519-signature-2018)
[![Dependency Status](https://img.shields.io/david/digitalbazaar/ed25519-signature-2018.svg)](https://david-dm.org/digitalbazaar/ed25519-signature-2018)
[![NPM Version](https://img.shields.io/npm/v/digitalbazaar/ed25519-signature-2018.svg)](https://npm.im/digitalbazaar/ed25519-signature-2018)

> Ed25519Signature2018 Linked Data Proof suite for use with jsonld-signatures.

Expand All @@ -16,7 +19,7 @@

## Background

For use with https://github.com/digitalbazaar/jsonld-signatures v6.0 and above.
For use with https://github.com/digitalbazaar/jsonld-signatures v8.0 and above.

## Security

Expand Down
78 changes: 78 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
*/
module.exports = function(config) {

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: ['mocha', 'chai'],

// list of files / patterns to load in the browser
files: [
'test/*.spec.js'
],

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

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

webpack: {
//mode: 'production',
mode: 'development',
devtool: 'inline-source-map'
},

// 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
// browser launchers: https://npmjs.org/browse/keyword/karma-launcher
//browsers: ['ChromeHeadless', 'Chrome', 'Firefox', 'Safari'],
browsers: ['ChromeHeadless'],

// 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
}
}
});
};
37 changes: 35 additions & 2 deletions lib/Ed25519Signature2018.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
/*!
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
*/
export class Ed25519Signature2018 {}

import {JwsLinkedDataSignature} from '@digitalbazaar/jws-linked-data-signature';
import {
Ed25519VerificationKey2018
} from '@digitalbazaar/ed25519-verification-key-2018';

export class Ed25519Signature2018 extends JwsLinkedDataSignature {
/**
* @param type {string} Provided by subclass.
*
* @param [verificationMethod] {string} A key id URL to the paired public key.
*
* This parameter is required for signing:
*
* @param [signer] {function} an optional signer.
*
* Advanced optional parameters and overrides:
*
* @param [proof] {object} a JSON-LD document with options to use for
* the `proof` node (e.g. any other custom fields can be provided here
* using a context different from security-v2).
* @param [date] {string|Date} signing date to use if not passed.
* @param [key] {LDKeyPair} an optional crypto-ld KeyPair.
* @param [useNativeCanonize] {boolean} true to use a native canonize
* algorithm.
*/
constructor({
signer, key, verificationMethod, proof, date, useNativeCanonize} = {}) {
super({type: 'Ed25519Signature2018', alg: 'EdDSA',
LDKeyClass: Ed25519VerificationKey2018, verificationMethod, signer, key,
proof, date, useNativeCanonize});
this.requiredKeyType = 'Ed25519VerificationKey2018';
}
}
8 changes: 0 additions & 8 deletions lib/env.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
*/
'use strict';

Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
*/
export {Ed25519Signature2018} from './Ed25519Signature2018.js';
25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@
],
"module": "lib/main.js",
"dependencies": {
"@digitalbazaar/ed25519-verification-key-2018": "^3.0.0",
"@digitalbazaar/jws-linked-data-signature": "^1.0.0",
"esm": "^3.2.25"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@babel/runtime": "^7.11.0",
"babel-loader": "^8.1.0",
"@transmute/jsonld-document-loader": "^0.2.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"dirty-chai": "^2.0.1",
"ed25519-signature-2018-context": "^1.0.0",
"eslint": "^7.6.0",
"eslint-config-digitalbazaar": "^2.5.0",
"eslint-plugin-jsdoc": "^30.2.0",
"eslint-config-digitalbazaar": "^2.6.1",
"eslint-plugin-jsdoc": "^32.3.0",
"jsonld-signatures": "^8.0.0",
"karma": "^5.1.1",
"karma-babel-preprocessor": "^8.0.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
Expand All @@ -53,7 +50,7 @@
},
"nyc": {
"exclude": [
"tests"
"test"
],
"reporter": [
"html",
Expand All @@ -74,10 +71,10 @@
],
"scripts": {
"test": "npm run lint && npm run test-node && npm run test-karma",
"test-node": "cross-env NODE_ENV=test mocha -r esm --preserve-symlinks -t 10000 tests/**/*.spec.js",
"test-karma": "karma start tests/karma.conf.js",
"test-karma": "karma start karma.conf.js",
"test-node": "cross-env NODE_ENV=test mocha -r esm --preserve-symlinks -t 30000 -R ${REPORTER:-spec} test/*.spec.js",
"coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node",
"coverage-ci": "cross-env NODE_ENV=test nyc --reporter=text-lcov npm run test-node > coverage.lcov",
"coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly npm run test-node",
"coverage-report": "nyc report",
"lint": "eslint ."
}
Expand Down
16 changes: 16 additions & 0 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*!
* Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
*/
module.exports = {
globals: {
should: true,
assertNoError: true
},
env: {
node: true,
mocha: true
},
extends: [
'digitalbazaar'
]
};
Loading