Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akismet-api

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akismet-api - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

LICENSE.txt

16

lib/akismet.js

@@ -23,3 +23,3 @@

this.endpoint = options.endpoint || this.key + '.' + this.host + '/' + this.version + '/';
this.userAgent = options.userAgent || 'Node.js/' + process.version + ' | Akismet-api/1.0.0';
this.userAgent = options.userAgent || 'Node.js/' + process.version + ' | Akismet-api/1.1.0';

@@ -42,3 +42,8 @@ /*

else if (res.text == 'valid') cb(null, true);
else cb(new Error(res.header['x-akismet-debug-help']), false);
else if (res.header['x-akismet-debug-help'])
cb(new Error(res.header['x-akismet-debug-help']), false);
else if (res.text == 'invalid')
cb(new Error('Invalid API key'), false);
else
cb(new Error(res.text), false);
});

@@ -75,3 +80,8 @@ };

else if (res.text == 'false') cb(null, false);
else cb(new Error(res.header['x-akismet-debug-help']), null);
else if (res.header['x-akismet-debug-help'])
cb(new Error(res.header['x-akismet-debug-help']), null);
else if (res.text == 'invalid')
cb(new Error('Invalid API key'), null);
else
cb(new Error(res.text), null);
});

@@ -78,0 +88,0 @@ };

2

package.json
{
"name": "akismet-api",
"version": "1.0.0",
"version": "1.1.0",
"description": "Nodejs bindings to the Akismet (http://akismet.com) spam detection service",

@@ -5,0 +5,0 @@ "main": "lib/akismet.js",

@@ -133,1 +133,7 @@ Akismet-api

License
-------
Released under the MIT license.
See [LICENSE.txt](LICENSE.txt) for more information.

@@ -49,3 +49,3 @@

expect(client.port).to.equal(80);
expect(client.userAgent).to.equal('Node.js/' + process.version + ' | Akismet-api/0.0.1');
expect(client.userAgent).to.equal('Node.js/' + process.version + ' | Akismet-api/1.1.0');
expect(client.version).to.equal('1.1');

@@ -97,2 +97,81 @@ });

describe('when the x-akismet-debug-help header is present', function() {
var client;
var scope;
beforeEach(function() {
client = Akismet.client({
blog : 'http://example.com',
key : 'testKey2',
host : 'rest2.akismet.com'
});
scope = nock('http://rest2.akismet.com')
.matchHeader('Content-Type', 'application/x-www-form-urlencoded')
.post('/1.1/verify-key')
.reply(200, 'invalid', {
'Content-Type' : 'text/plain',
'X-akismet-debug-help' : 'Could not find your key'
});
});
it('should return false', function(done) {
client.verifyKey(function(err, valid) {
expect(valid).to.be.false;
scope.done();
done();
});
});
it('should return the akismet debug error', function(done) {
client.verifyKey(function(err, valid) {
expect(err.message).to.equal('Could not find your key');
scope.done();
done();
});
});
});
describe('when the x-akismet-debug-help header is not present', function() {
var client;
var scope;
beforeEach(function() {
client = Akismet.client({
blog : 'http://example.com',
key : 'testKey2',
host : 'rest2.akismet.com'
});
scope = nock('http://rest2.akismet.com')
.matchHeader('Content-Type', 'application/x-www-form-urlencoded')
.post('/1.1/verify-key')
.reply(200, 'invalid', {
'Content-Type' : 'text/plain'
});
});
it('should return false', function(done) {
client.verifyKey(function(err, valid) {
expect(valid).to.be.false;
scope.done();
done();
});
});
it('should return \'Invalid API key\'', function(done) {
client.verifyKey(function(err, valid) {
expect(err.message).to.equal('Invalid API key');
scope.done();
done();
});
});
});
});
describe('when the request returns anything else', function() {
var client;

@@ -110,5 +189,4 @@ var scope;

.post('/1.1/verify-key')
.reply(200, 'invalid', {
'Content-Type' : 'text/plain',
'X-akismet-debug-help' : 'Could not find your key'
.reply(200, 'whatisthiserror', {
'Content-Type' : 'text/plain'
});

@@ -125,5 +203,5 @@ });

it('should return the akismet debug error', function(done) {
it('should return the response', function(done) {
client.verifyKey(function(err, valid) {
expect(err.message).to.equal('Could not find your key');
expect(err.message).to.equal('whatisthiserror');
scope.done();

@@ -250,38 +328,82 @@ done();

describe('when the request returns something else', function() {
describe('when the x-akismet-debug-help header is present', function() {
var client;
var scope;
var client;
var scope;
beforeEach(function() {
client = Akismet.client({
blog : 'http://example.com',
key : 'testKey6'
});
scope = nock('http://testKey6.rest.akismet.com')
.matchHeader('Content-Type', 'application/x-www-form-urlencoded')
.post('/1.1/comment-check')
.reply(200, 'notAValidValueAtAll', {
'Content-Type' : 'text/plain',
'X-akismet-debug-help' : 'You did something wrong!'
});
});
it('should return null', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(spam).to.be.null;
scope.done();
done();
});
});
beforeEach(function() {
client = Akismet.client({
blog : 'http://example.com',
key : 'testKey6'
it('should return the akismet debug error', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(err.message).to.equal('You did something wrong!');
scope.done();
done();
});
});
scope = nock('http://testKey6.rest.akismet.com')
.matchHeader('Content-Type', 'application/x-www-form-urlencoded')
.post('/1.1/comment-check')
.reply(200, 'notAValidValueAtAll', {
'Content-Type' : 'text/plain',
'X-akismet-debug-help' : 'You did something wrong!'
});
});
it('should return null', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(spam).to.be.null;
scope.done();
done();
});
});
describe('when the x-akismet-debug-help header is not present', function() {
it('should return the akismet debug error', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(err.message).to.equal('You did something wrong!');
scope.done();
done();
var client;
var scope;
beforeEach(function() {
client = Akismet.client({
blog : 'http://example.com',
key : 'testKey6'
});
scope = nock('http://testKey6.rest.akismet.com')
.matchHeader('Content-Type', 'application/x-www-form-urlencoded')
.post('/1.1/comment-check')
.reply(200, 'notAValidValueAtAll', {
'Content-Type' : 'text/plain'
});
});
it('should return null', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(spam).to.be.null;
scope.done();
done();
});
});
it('should return the response', function(done) {
client.checkSpam({
user_ip : '123.123.123.123'
}, function(err, spam) {
expect(err.message).to.equal('notAValidValueAtAll');
scope.done();
done();
});
});
});

@@ -288,0 +410,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc