solid-server 5.8.6 → 5.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,35 @@
1
1
  module.exports = get
2
2
 
3
- const request = require('request')
3
+ const fetch = require('node-fetch')
4
4
  const url = require('url')
5
5
 
6
6
  function get (webid, callback) {
7
- const uri = url.URL(webid)
8
- const options = {
9
- url: uri,
10
- method: 'GET',
11
- headers: {
12
- Accept: 'text/turtle, application/ld+json'
13
- }
7
+ let uri
8
+ try {
9
+ uri = new url.URL(webid)
10
+ } catch (err) {
11
+ return callback(new Error('Invalid WebID URI: ' + webid + ': ' + err.message))
14
12
  }
15
13
 
16
- request(options, function (err, res, body) {
17
- if (err) {
18
- return callback(new Error('Failed to fetch profile from ' + uri.href + ': ' + err))
19
- }
20
-
21
- if (res.statusCode !== 200) {
22
- return callback(new Error('Failed to retrieve WebID from ' + uri.href + ': HTTP ' + res.statusCode))
23
- }
14
+ const headers = {
15
+ Accept: 'text/turtle, application/ld+json'
16
+ }
24
17
 
25
- callback(null, body, res.headers['content-type'])
26
- })
18
+ fetch(uri.href, { method: 'GET', headers })
19
+ .then(async res => {
20
+ if (!res.ok) {
21
+ return callback(new Error('Failed to retrieve WebID from ' + uri.href + ': HTTP ' + res.status))
22
+ }
23
+ const contentType = res.headers.get('content-type')
24
+ let body
25
+ if (contentType && contentType.includes('json')) {
26
+ body = JSON.stringify(await res.json(), null, 2)
27
+ } else {
28
+ body = await res.text()
29
+ }
30
+ callback(null, body, contentType)
31
+ })
32
+ .catch(err => {
33
+ return callback(new Error('Failed to fetch profile from ' + uri.href + ': ' + err))
34
+ })
27
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-server",
3
3
  "description": "Solid server on top of the file-system",
4
- "version": "5.8.6",
4
+ "version": "5.8.7",
5
5
  "author": {
6
6
  "name": "Tim Berners-Lee",
7
7
  "email": "timbl@w3.org"
@@ -60,9 +60,10 @@
60
60
  "bugs": "https://github.com/solid/node-solid-server/issues",
61
61
  "dependencies": {
62
62
  "@fastify/busboy": "^1.2.1",
63
+ "@fastify/pre-commit": "^2.2.1",
63
64
  "@solid/acl-check": "^0.4.5",
64
- "@solid/oidc-auth-manager": "^0.24.3",
65
- "@solid/oidc-op": "^0.11.6",
65
+ "@solid/oidc-auth-manager": "^0.24.5",
66
+ "@solid/oidc-op": "^0.11.7",
66
67
  "async-lock": "^1.4.1",
67
68
  "body-parser": "^1.20.3",
68
69
  "bootstrap": "^3.4.1",
@@ -98,12 +99,12 @@
98
99
  "node-fetch": "^2.7.0",
99
100
  "node-forge": "^1.3.1",
100
101
  "node-mailer": "^0.1.1",
101
- "nodemailer": "^6.10.0",
102
+ "nodemailer": "^7.0.10",
102
103
  "nyc": "^15.1.0",
103
104
  "oidc-op-express": "^0.0.3",
104
105
  "owasp-password-strength-test": "^1.3.0",
106
+ "rdflib": "^2.3.0",
105
107
  "recursive-readdir": "^2.2.3",
106
- "request": "^2.88.2",
107
108
  "rimraf": "^3.0.2",
108
109
  "solid-auth-client": "^2.5.6",
109
110
  "solid-namespace": "^0.5.4",
@@ -129,7 +130,6 @@
129
130
  "mocha": "^10.8.2",
130
131
  "nock": "^13.5.6",
131
132
  "node-mocks-http": "^1.16.2",
132
- "pre-commit": "1.2.2",
133
133
  "prep-fetch": "^0.1.0",
134
134
  "randombytes": "2.1.0",
135
135
  "sinon": "12.0.1",