Skip to content

Commit 6995c16

Browse files
committed
Convert to module (ESM).
- **BREAKING**: Convert to module (ESM). - **BREAKING**: Require Node.js >=14. - Update dependencies. - Lint module.
1 parent 7e14ef2 commit 6995c16

26 files changed

+781
-783
lines changed

.babelrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*!
2+
* Copyright (c) 2021-2022 Digital Bazaar, Inc. All rights reserved.
3+
*/
4+
module.exports = {
5+
root: true,
6+
env: {
7+
node: true
8+
},
9+
extends: [
10+
'digitalbazaar',
11+
'digitalbazaar/jsdoc',
12+
'digitalbazaar/module'
13+
],
14+
rules: {
15+
'jsdoc/require-description-complete-sentence': 0
16+
}
17+
};

.eslintrc.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
timeout-minutes: 10
99
strategy:
1010
matrix:
11-
node-version: [12.x, 14.x]
11+
node-version: [14.x, 16.x, 18.x]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Use Node.js ${{ matrix.node-version }}
@@ -23,7 +23,7 @@ jobs:
2323
timeout-minutes: 10
2424
strategy:
2525
matrix:
26-
node-version: [14.x]
26+
node-version: [16.x]
2727
steps:
2828
- uses: actions/checkout@v2
2929
- name: Use Node.js ${{ matrix.node-version }}
@@ -38,7 +38,7 @@ jobs:
3838
timeout-minutes: 10
3939
strategy:
4040
matrix:
41-
node-version: [14.x]
41+
node-version: [16.x]
4242
steps:
4343
- uses: actions/checkout@v2
4444
- name: Use Node.js ${{ matrix.node-version }}
@@ -54,7 +54,7 @@ jobs:
5454
timeout-minutes: 10
5555
strategy:
5656
matrix:
57-
node-version: [14.x]
57+
node-version: [16.x]
5858
steps:
5959
- uses: actions/checkout@v2
6060
- name: Use Node.js ${{ matrix.node-version }}
@@ -65,7 +65,7 @@ jobs:
6565
- name: Generate coverage report
6666
run: npm run coverage-ci
6767
- name: Upload coverage to Codecov
68-
uses: codecov/codecov-action@v1
68+
uses: codecov/codecov-action@v2
6969
with:
7070
file: ./coverage/lcov.info
7171
fail_ci_if_error: true

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# @digitalbazaar/vc ChangeLog
22

3+
## 3.0.0 - 2022-xx-xx
4+
5+
### Changed
6+
- **BREAKING**: Convert to module (ESM).
7+
- **BREAKING**: Require Node.js >=14.
8+
- Update dependencies.
9+
- **BREAKING**: `[email protected]` used in tests.
10+
- Lint module.
11+
312
## 2.1.0 - 2021-12-20
413

514
### Changed

karma.conf.js renamed to karma.conf.cjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2021-2022 Digital Bazaar, Inc. All rights reserved.
33
*/
44
module.exports = function(config) {
55

@@ -26,16 +26,8 @@ module.exports = function(config) {
2626
},
2727

2828
webpack: {
29-
//mode: 'production',
3029
mode: 'development',
31-
devtool: 'inline-source-map',
32-
resolve: {
33-
fallback: {
34-
crypto: false,
35-
url: false,
36-
util: false
37-
}
38-
}
30+
devtool: 'inline-source-map'
3931
},
4032

4133
// test results reporter to use

lib/CredentialIssuancePurpose.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
/*!
2-
* Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
'use strict';
5-
const jsonld = require('jsonld');
6-
const {AssertionProofPurpose} = require('jsonld-signatures').purposes;
4+
import jsonld from 'jsonld';
5+
import jsigs from 'jsonld-signatures';
6+
7+
const {purposes: {AssertionProofPurpose}} = jsigs;
78

89
/**
910
* Creates a proof purpose that will validate whether or not the verification
1011
* method in a proof was authorized by its declared controller for the
1112
* proof's purpose.
1213
*/
13-
class CredentialIssuancePurpose extends AssertionProofPurpose {
14+
export class CredentialIssuancePurpose extends AssertionProofPurpose {
1415
/**
1516
* @param {object} options - The options to use.
1617
* @param {object} [options.controller] - The description of the controller,
@@ -77,5 +78,3 @@ class CredentialIssuancePurpose extends AssertionProofPurpose {
7778
}
7879
}
7980
}
80-
81-
module.exports = CredentialIssuancePurpose;

lib/contexts/index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
/*!
2-
* Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
'use strict';
4+
import {
5+
contexts as credentialContexts
6+
} from 'credentials-context';
7+
import {
8+
CONTEXT as vcExamplesV1Context,
9+
CONTEXT_URL as vcExamplesV1ContextUrl
10+
} from './vc-examples-v1.js';
11+
import {
12+
CONTEXT as odrlContext,
13+
CONTEXT_URL as odrlContextUrl
14+
} from './odrl.js';
515

6-
const {contexts, constants: contextConstants} = require('credentials-context');
16+
export const contexts = {};
717

8-
const exportedContexts = module.exports = {
9-
'https://www.w3.org/2018/credentials/examples/v1':
10-
require('./vc-examples-v1'),
11-
'https://www.w3.org/ns/odrl.jsonld': require('./odrl')
12-
};
18+
contexts[vcExamplesV1ContextUrl] = vcExamplesV1Context;
19+
contexts[odrlContextUrl] = odrlContext;
1320

14-
for(const c in contextConstants) {
15-
const contextUrl = contextConstants[c];
16-
exportedContexts[contextUrl] = contexts.get(contextUrl);
21+
for(const [url, context] of credentialContexts.entries()) {
22+
contexts[url] = context;
1723
}

lib/contexts/odrl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*!
2-
* Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
33
*/
4-
'use strict';
54

5+
export const CONTEXT_URL = 'https://www.w3.org/ns/odrl.jsonld';
66
/* eslint-disable quote-props, key-spacing, max-len */
7-
module.exports = {
7+
export const CONTEXT = {
88
'@context': {
99
'odrl': 'http://www.w3.org/ns/odrl/2/',
1010
'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',

lib/contexts/vc-examples-v1.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*!
2-
* Copyright (c) 2019-2021 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
33
*/
44

5+
export const CONTEXT_URL = 'https://www.w3.org/2018/credentials/examples/v1';
56
/* eslint-disable quote-props */
6-
module.exports = {
7+
export const CONTEXT = {
78
'@context': [
89
{
910
'@version': 1.1

0 commit comments

Comments
 (0)