Skip to content

Commit 97322a0

Browse files
RubenVerborghdmitrizagidulin
authored andcommitted
Make x509 dependency optional.
This is a native module, which might not compile on all platforms. Furthermore, it is only needed for header-based WebID auth.
1 parent 180a114 commit 97322a0

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎lib/api/authn/webid-tls.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var webid = require('webid/tls')
22
var debug = require('../../debug').authentication
3-
var x509 = require('x509')
3+
var x509 // optional dependency, load lazily
44

55
const CERTIFICATE_MATCHER = /^-----BEGIN CERTIFICATE-----\n(?:[A-Za-z0-9+/=]+\n)+-----END CERTIFICATE-----$/m
66

@@ -65,6 +65,7 @@ function getCertificateViaHeader (req) {
6565
}
6666

6767
// Parse and convert the certificate to the format the webid library expects
68+
if (!x509) x509 = require('x509')
6869
try {
6970
const { publicKey, extensions } = x509.parseCert(rawCertificate)
7071
return {

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373
"uuid": "^3.0.0",
7474
"valid-url": "^1.0.9",
7575
"vhost": "^3.0.2",
76-
"webid": "^0.3.7",
76+
"webid": "^0.3.7"
77+
},
78+
"optionalDependencies": {
7779
"x509": "^0.3.2"
7880
},
7981
"devDependencies": {

0 commit comments

Comments
 (0)