Skip to content

Commit ce7f2be

Browse files
committed
Merge branch 'v6.x'
2 parents b7bc6d6 + 345bc00 commit ce7f2be

File tree

6 files changed

+72
-19
lines changed

6 files changed

+72
-19
lines changed

.eslintrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@ module.exports = {
66
es2020: true
77
},
88
extends: 'eslint-config-digitalbazaar',
9-
root: true
9+
root: true,
10+
ignorePatterns: [
11+
'dist/',
12+
'tests/webidl/WebIDLParser.js',
13+
'tests/webidl/idlharness.js',
14+
'tests/webidl/testharness.js'
15+
]
1016
};

.github/workflows/main.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@ name: Node.js CI
33
on: [push]
44

55
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 10
9+
strategy:
10+
matrix:
11+
node-version: [16.x]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Use Node.js ${{ matrix.node-version }}
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: ${{ matrix.node-version }}
18+
- run: npm install
19+
- name: Run eslint
20+
run: npm run lint
621
test-node:
722
runs-on: ubuntu-latest
823
timeout-minutes: 10
924
strategy:
1025
matrix:
11-
node-version: [12.x, 14.x, 16.x]
26+
node-version: [14.x, 16.x, 18.x]
1227
steps:
1328
- uses: actions/checkout@v2
1429
- name: Use Node.js ${{ matrix.node-version }}
@@ -26,7 +41,7 @@ jobs:
2641
timeout-minutes: 10
2742
strategy:
2843
matrix:
29-
node-version: [14.x]
44+
node-version: [16.x]
3045
bundler: [webpack, browserify]
3146
steps:
3247
- uses: actions/checkout@v2
@@ -42,28 +57,28 @@ jobs:
4257
run: npm run test-karma
4358
env:
4459
BUNDLER: ${{ matrix.bundler }}
45-
lint:
60+
build:
4661
runs-on: ubuntu-latest
4762
timeout-minutes: 10
4863
strategy:
4964
matrix:
50-
node-version: [14.x]
65+
node-version: [16.x]
5166
steps:
5267
- uses: actions/checkout@v2
5368
- name: Use Node.js ${{ matrix.node-version }}
5469
uses: actions/setup-node@v1
5570
with:
5671
node-version: ${{ matrix.node-version }}
5772
- run: npm install
58-
- name: Run eslint
59-
run: npm run lint
73+
- name: Run build
74+
run: npm run build
6075
coverage:
6176
needs: [test-node, test-karma]
6277
runs-on: ubuntu-latest
6378
timeout-minutes: 10
6479
strategy:
6580
matrix:
66-
node-version: [14.x]
81+
node-version: [16.x]
6782
steps:
6883
- uses: actions/checkout@v2
6984
- name: Use Node.js ${{ matrix.node-version }}

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
### Changed
1010
- Change EARL Assertor to Digital Bazaar, Inc.
1111

12+
## 6.0.0 - 2022-06-06
13+
14+
### Changed
15+
- **BREAKING**: Drop testing and support for Node.js 12.x. The majority of the
16+
code will still run on Node.js 12.x. However, the
17+
`@digitalbazaar/http-client@3` update uses a newer `ky-universal` which uses
18+
a top-level `await` that is unsupported in older Node.js versions. That
19+
causes the included `node` `documentLoader` to not function and tests to
20+
fail. If you wish to still use earlier Node.js versions, you may still be
21+
able to do so with your own custom `documentLoader`.
22+
- **BREAKING**: `npm` `prepublish` script changed to `prepack`. The `dist/`
23+
contents will not be generated by default for development installs. Run `npm
24+
run build` if needed. This was done to avoid extra work only needed for
25+
packing and publication, and for temporary `webpack` version issues. A new CI
26+
`build` test has been added to check builds pass. The `prepack` script could
27+
be `prepare` instead if use cases exist where that is needed. File an issue
28+
if this is a concern.
29+
- Update to `@digitalbazaar/http-client@3`:
30+
- Pulls in newer `ky` and `ky-universal` that should address security alerts
31+
and provide other improvements.
32+
- Use global `URL` interface to handle relative redirects.
33+
1234
## 5.2.0 - 2021-04-07
1335

1436
### Changed

lib/documentLoaders/node.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ module.exports = ({
8080
url, headers, strictSSL, httpAgent, httpsAgent
8181
});
8282
doc = {contextUrl: null, documentUrl: url, document: body || null};
83+
8384
// handle error
8485
const statusText = http.STATUS_CODES[res.status];
8586
if(res.status >= 400) {
@@ -92,7 +93,9 @@ module.exports = ({
9293
});
9394
}
9495
const link = res.headers.get('link');
96+
let location = res.headers.get('location');
9597
const contentType = res.headers.get('content-type');
98+
9699
// handle Link Header
97100
if(link && contentType !== 'application/ld+json') {
98101
// only 1 related link header permitted
@@ -110,15 +113,15 @@ module.exports = ({
110113
}
111114

112115
// "alternate" link header is a redirect
113-
alternate = linkHeaders['alternate'];
116+
alternate = linkHeaders.alternate;
114117
if(alternate &&
115118
alternate.type == 'application/ld+json' &&
116119
!(contentType || '')
117120
.match(/^application\/(\w*\+)?json$/)) {
118-
res.headers.set('location', prependBase(url, alternate.target));
121+
location = prependBase(url, alternate.target);
119122
}
120123
}
121-
const location = res.headers.get('location');
124+
122125
// handle redirect
123126
if((alternate ||
124127
res.status >= 300 && res.status < 400) && location) {
@@ -143,7 +146,9 @@ module.exports = ({
143146
});
144147
}
145148
redirects.push(url);
146-
return loadDocument(location, redirects);
149+
// location can be relative, turn into full url
150+
const nextUrl = new URL(location, url).href;
151+
return loadDocument(nextUrl, redirects);
147152
}
148153

149154
// cache for each redirected URL
@@ -163,7 +168,12 @@ module.exports = ({
163168

164169
async function _fetch({url, headers, strictSSL, httpAgent, httpsAgent}) {
165170
try {
166-
const options = {headers, redirect: 'manual'};
171+
const options = {
172+
headers,
173+
redirect: 'manual',
174+
// ky specific to avoid redirects throwing
175+
throwHttpErrors: false
176+
};
167177
const isHttps = url.startsWith('https:');
168178
if(isHttps) {
169179
options.agent =

lib/documentLoaders/xhr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module.exports = ({
9090
}
9191

9292
// "alternate" link header is a redirect
93-
alternate = linkHeaders['alternate'];
93+
alternate = linkHeaders.alternate;
9494
if(alternate &&
9595
alternate.type == 'application/ld+json' &&
9696
!(contentType || '').match(/^application\/(\w*\+)?json$/)) {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsonld",
3-
"version": "5.2.1-0",
3+
"version": "6.0.1-0",
44
"description": "A JSON-LD Processor and API implementation in JavaScript.",
55
"homepage": "https://github.com/digitalbazaar/jsonld.js",
66
"author": {
@@ -29,7 +29,7 @@
2929
"lib/**/*.js"
3030
],
3131
"dependencies": {
32-
"@digitalbazaar/http-client": "^1.1.0",
32+
"@digitalbazaar/http-client": "^3.2.0",
3333
"canonicalize": "^1.0.1",
3434
"lru-cache": "^6.0.0",
3535
"rdf-canonize": "^3.0.0"
@@ -78,7 +78,7 @@
7878
"webpack-merge": "^5.7.3"
7979
},
8080
"engines": {
81-
"node": ">=12"
81+
"node": ">=14"
8282
},
8383
"keywords": [
8484
"JSON",
@@ -89,7 +89,7 @@
8989
"jsonld"
9090
],
9191
"scripts": {
92-
"prepublish": "npm run build",
92+
"prepack": "npm run build",
9393
"build": "npm run build-webpack",
9494
"build-webpack": "webpack",
9595
"fetch-test-suites": "npm run fetch-json-ld-wg-test-suite && npm run fetch-json-ld-org-test-suite && npm run fetch-normalization-test-suite",
@@ -104,7 +104,7 @@
104104
"coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm test",
105105
"coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly npm run test",
106106
"coverage-report": "nyc report",
107-
"lint": "eslint *.js lib/**.js tests/**.js"
107+
"lint": "eslint ."
108108
},
109109
"nyc": {
110110
"exclude": [

0 commit comments

Comments
 (0)