Comparing version 0.1.0 to 0.1.1
@@ -45,3 +45,10 @@ const https = require('https'); | ||
.on('data', (chunk) => buffer += chunk) | ||
.on('end', () => resolve(JSON.parse(buffer))) | ||
.on('end', () => { | ||
try { | ||
const json = JSON.parse(buffer); | ||
resolve(json); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
}); | ||
}); | ||
@@ -48,0 +55,0 @@ |
{ | ||
"name": "hcaptcha", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Verify hCaptcha token", | ||
@@ -25,5 +25,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "^8.2.1", | ||
"nock": "^13.1.1" | ||
"mocha": "^9.1.3", | ||
"nock": "^13.2.1" | ||
} | ||
} |
@@ -75,2 +75,14 @@ 'use strict'; | ||
it('throws on invalid json response', function (done) { | ||
nock('https://hcaptcha.com') | ||
.post('/siteverify', 'secret=mysecret&response=token') | ||
.reply(200, '<html lang="en">...'); | ||
verify(secret, token) | ||
.then(done.fail) | ||
.catch(error => { | ||
assert.strictEqual(error.message, 'Unexpected token < in JSON at position 0') | ||
done() | ||
}); | ||
}); | ||
it('throws on http failure', function (done) { | ||
@@ -82,5 +94,5 @@ nock('https://hcaptcha.com') | ||
.then(done.fail) | ||
.catch(() => done()) | ||
.catch(() => done()); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7323
171