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

@cedx/akismet

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cedx/akismet - npm Package Compare versions

Comparing version 16.0.2 to 16.1.0

lib/author.js

83

lib/author.d.ts
/**
* Represents the author of a comment.
*/
export class Author {
export declare class Author {
/**
* Creates a new author from the specified JSON object.
* @param {Record<string, any>} json A JSON object representing an author.
* @returns {Author} The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Author;
/**
* Creates a new author.
* @param {AuthorOptions} [options] An object providing values to initialize this instance.
*/
constructor(options?: AuthorOptions | undefined);
/**
* The author's mail address. If you set it to `"akismet-guaranteed-spam@example.com"`, Akismet will always return `true`.
* @type {string}
*/

@@ -23,3 +11,2 @@ email: string;

* The author's IP address.
* @type {string}
*/

@@ -29,3 +16,2 @@ ipAddress: string;

* The author's name. If you set it to `"viagra-test-123"`, Akismet will always return `true`.
* @type {string}
*/

@@ -35,8 +21,6 @@ name: string;

* The author's role. If you set it to `"administrator"`, Akismet will always return `false`.
* @type {AuthorRole}
*/
role: AuthorRole;
role: AuthorRole | string;
/**
* The URL of the author's website.
* @type {URL|null}
*/

@@ -46,8 +30,18 @@ url: URL | null;

* The author's user agent, that is the string identifying the Web browser used to submit comments.
* @type {string}
*/
userAgent: string;
/**
* Creates a new author.
* @param options An object providing values to initialize this instance.
*/
constructor(options?: Partial<AuthorOptions>);
/**
* Creates a new author from the specified JSON object.
* @param json A JSON object representing an author.
* @returns The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Author;
/**
* Converts this object to a map in JSON format.
* @returns {Record<string, any>} The map in JSON format corresponding to this object.
* @returns The map in JSON format corresponding to this object.
*/

@@ -57,52 +51,39 @@ toJSON(): Record<string, any>;

/**
* Specifies the role of an author.
*/
export type AuthorRole = string;
/**
* Defines the options of an {@link Author} instance.
* @typedef {object} AuthorOptions
* @property {string} [email] The author's mail address.
* @property {string} [ipAddress] The author's IP address.
* @property {string} [name] The author's name.
* @property {AuthorRole} [role] The author's role.
* @property {string} [url] The URL of the author's website.
* @property {string} [userAgent] The author's user agent, that is the string identifying the Web browser used to submit comments.
*/
/**
* Specifies the role of an author.
* @enum {string}
*/
export const AuthorRole: Readonly<{
/** The author is an administrator. */
administrator: "administrator";
}>;
/**
* Defines the options of an {@link Author } instance.
*/
export type AuthorOptions = {
export interface AuthorOptions {
/**
* The author's mail address.
* The author's mail address. If you set it to `"akismet-guaranteed-spam@example.com"`, Akismet will always return `true`.
*/
email?: string | undefined;
email: string;
/**
* The author's IP address.
*/
ipAddress?: string | undefined;
ipAddress: string;
/**
* The author's name.
*/
name?: string | undefined;
name: string;
/**
* The author's role.
*/
role?: string | undefined;
role: AuthorRole | string;
/**
* The URL of the author's website.
*/
url?: string | undefined;
url: string;
/**
* The author's user agent, that is the string identifying the Web browser used to submit comments.
*/
userAgent?: string | undefined;
};
userAgent: string;
}
/**
* Specifies the role of an author.
*/
export declare enum AuthorRole {
/**
* The author is an administrator.
*/
administrator = "administrator"
}
//# sourceMappingURL=author.d.ts.map
/**
* Represents the front page or home URL transmitted when making requests.
*/
export class Blog {
export declare class Blog {
/**
* Creates a new blog from the specified JSON object.
* @param {Record<string, any>} json A JSON object representing a blog.
* @returns {Blog} The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Blog;
/**
* Creates a new blog.
* @param {BlogOptions} [options] An object providing values to initialize this instance.
*/
constructor(options?: BlogOptions | undefined);
/**
* The character encoding for the values included in comments.
* @type {string}
*/

@@ -23,3 +11,2 @@ charset: string;

* The languages in use on the blog or site, in ISO 639-1 format.
* @type {string[]}
*/

@@ -29,8 +16,18 @@ languages: string[];

* The blog or site URL.
* @type {URL|null}
*/
url: URL | null;
/**
* Creates a new blog.
* @param options An object providing values to initialize this instance.
*/
constructor(options: Partial<BlogOptions>);
/**
* Creates a new blog from the specified JSON object.
* @param json A JSON object representing a blog.
* @returns The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Blog;
/**
* Converts this object to a map in JSON format.
* @returns {Record<string, any>} The map in JSON format corresponding to this object.
* @returns The map in JSON format corresponding to this object.
*/

@@ -40,18 +37,18 @@ toJSON(): Record<string, any>;

/**
* Defines the options of a {@link Blog } instance.
* Defines the options of a {@link Blog} instance.
*/
export type BlogOptions = {
export interface BlogOptions {
/**
* The character encoding for the values included in comments.
*/
charset?: string | undefined;
charset: string;
/**
* The languages in use on the blog or site, in ISO 639-1 format.
*/
languages?: string[] | undefined;
languages: string[];
/**
* The blog or site URL.
*/
url?: string | undefined;
};
url: string;
}
//# sourceMappingURL=blog.d.ts.map
/**
* Specifies the result of a comment check.
*/
export type CheckResult = number;
/**
* Specifies the result of a comment check.
* @enum {number}
*/
export const CheckResult: Readonly<{
/** The comment is not a spam (i.e. a ham). */
ham: 0;
/** The comment is a spam. */
spam: 1;
/** The comment is a pervasive spam (i.e. it can be safely discarded). */
pervasiveSpam: 2;
}>;
export declare enum CheckResult {
/**
* The comment is not a spam (i.e. a ham).
*/
ham = 0,
/**
* The comment is a spam.
*/
spam = 1,
/**
* The comment is a pervasive spam (i.e. it can be safely discarded).
*/
pervasiveSpam = 2
}
//# sourceMappingURL=check_result.d.ts.map

@@ -0,26 +1,11 @@

import type { Blog } from "./blog.js";
import { CheckResult } from "./check_result.js";
import type { Comment } from "./comment.js";
/**
* Submits comments to the [Akismet](https://akismet.com) service.
*/
export class Client {
export declare class Client {
#private;
/**
* The response returned by the `submit-ham` and `submit-spam` endpoints when the outcome is a success.
* @type {string}
*/
static "__#1@#success": string;
/**
* The package version.
* @type {string}
*/
static "__#1@#version": string;
/**
* Creates a new client.
* @param {string} apiKey The Akismet API key.
* @param {import("./blog.js").Blog} blog The front page or home URL of the instance making requests.
* @param {ClientOptions} [options] An object providing values to initialize this instance.
*/
constructor(apiKey: string, blog: import("./blog.js").Blog, options?: ClientOptions | undefined);
/**
* The Akismet API key.
* @type {string}
* @readonly
*/

@@ -30,4 +15,2 @@ readonly apiKey: string;

* The base URL of the remote API endpoint.
* @type {URL}
* @readonly
*/

@@ -37,10 +20,6 @@ readonly baseUrl: URL;

* The front page or home URL of the instance making requests.
* @type {import("./blog.js").Blog}
* @readonly
*/
readonly blog: import("./blog.js").Blog;
readonly blog: Blog;
/**
* Value indicating whether the client operates in test mode.
* @type {boolean}
* @readonly
*/

@@ -50,49 +29,52 @@ readonly isTest: boolean;

* The user agent string to use when making requests.
* @type {string}
* @readonly
*/
readonly userAgent: string;
/**
* Creates a new client.
* @param apiKey The Akismet API key.
* @param blog The front page or home URL of the instance making requests.
* @param options An object providing values to initialize this instance.
*/
constructor(apiKey: string, blog: Blog, options?: Partial<ClientOptions>);
/**
* Checks the specified comment against the service database, and returns a value indicating whether it is spam.
* @param {import("./comment.js").Comment} comment The comment to be checked.
* @returns {Promise<CheckResult>} A value indicating whether the specified comment is spam.
* @param comment The comment to be checked.
* @returns A value indicating whether the specified comment is spam.
*/
checkComment(comment: import("./comment.js").Comment): Promise<CheckResult>;
checkComment(comment: Comment): Promise<CheckResult>;
/**
* Submits the specified comment that was incorrectly marked as spam but should not have been.
* @param {import("./comment.js").Comment} comment The comment to be submitted.
* @returns {Promise<void>} Resolves once the comment has been submitted.
* @param comment The comment to be submitted.
* @returns Resolves once the comment has been submitted.
*/
submitHam(comment: import("./comment.js").Comment): Promise<void>;
submitHam(comment: Comment): Promise<void>;
/**
* Submits the specified comment that was not marked as spam but should have been.
* @param {import("./comment.js").Comment} comment The comment to be submitted.
* @returns {Promise<void>} Resolves once the comment has been submitted.
* @param comment The comment to be submitted.
* @returns Resolves once the comment has been submitted.
*/
submitSpam(comment: import("./comment.js").Comment): Promise<void>;
submitSpam(comment: Comment): Promise<void>;
/**
* Checks the API key against the service database, and returns a value indicating whether it is valid.
* @returns {Promise<boolean>} `true` if the specified API key is valid, otherwise `false`.
* @returns `true` if the specified API key is valid, otherwise `false`.
*/
verifyKey(): Promise<boolean>;
#private;
}
/**
* Defines the options of a {@link Client } instance.
* Defines the options of a {@link Client} instance.
*/
export type ClientOptions = {
export interface ClientOptions {
/**
* The base URL of the remote API endpoint.
*/
baseUrl?: string | undefined;
baseUrl: string;
/**
* Value indicating whether the client operates in test mode.
*/
isTest?: boolean | undefined;
isTest: boolean;
/**
* The user agent string to use when making requests.
*/
userAgent?: string | undefined;
};
import { CheckResult } from "./check_result.js";
userAgent: string;
}
//# sourceMappingURL=client.d.ts.map

@@ -0,19 +1,8 @@

import { Author } from "./author.js";
/**
* Represents a comment submitted by an author.
*/
export class Comment {
export declare class Comment {
/**
* Creates a new comment from the specified JSON object.
* @param {Record<string, any>} json A JSON object representing a comment.
* @returns {Comment} The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Comment;
/**
* Creates a new comment.
* @param {CommentOptions} [options] An object providing values to initialize this instance.
*/
constructor(options?: CommentOptions | undefined);
/**
* The comment's author.
* @type {Author|null}
*/

@@ -23,8 +12,10 @@ author: Author | null;

* The comment's content.
* @type {string}
*/
content: string;
/**
* The context in which this comment was posted.
*/
context: string[];
/**
* The UTC timestamp of the creation of the comment.
* @type {Date|null}
*/

@@ -34,3 +25,2 @@ date: Date | null;

* The permanent location of the entry the comment is submitted to.
* @type {URL|null}
*/

@@ -40,3 +30,2 @@ permalink: URL | null;

* The UTC timestamp of the publication time for the post, page or thread on which the comment was posted.
* @type {Date|null}
*/

@@ -46,3 +35,2 @@ postModified: Date | null;

* A string describing why the content is being rechecked.
* @type {string}
*/

@@ -52,3 +40,2 @@ recheckReason: string;

* The URL of the webpage that linked to the entry being requested.
* @type {URL|null}
*/

@@ -58,8 +45,18 @@ referrer: URL | null;

* The comment's type.
* @type {CommentType}
*/
type: CommentType;
type: CommentType | string;
/**
* Creates a new comment.
* @param options An object providing values to initialize this instance.
*/
constructor(options: Partial<CommentOptions>);
/**
* Creates a new comment from the specified JSON object.
* @param json A JSON object representing a comment.
* @returns The instance corresponding to the specified JSON object.
*/
static fromJson(json: Record<string, any>): Comment;
/**
* Converts this object to a map in JSON format.
* @returns {Record<string, any>} The map in JSON format corresponding to this object.
* @returns The map in JSON format corresponding to this object.
*/

@@ -69,75 +66,75 @@ toJSON(): Record<string, any>;

/**
* Specifies the type of a comment.
*/
export type CommentType = string;
/**
* Defines the options of a {@link Comment} instance.
* @typedef {object} CommentOptions
* @property {Author|null} [author] The comment's author.
* @property {string} [content] The comment's content.
* @property {Date|null} [date] The UTC timestamp of the creation of the comment.
* @property {string} [permalink] The permanent location of the entry the comment is submitted to.
* @property {Date|null} [postModified] The UTC timestamp of the publication time for the post, page or thread on which the comment was posted.
* @property {string} [recheckReason] A string describing why the content is being rechecked.
* @property {string} [referrer] The URL of the webpage that linked to the entry being requested.
* @property {string} [type] The comment's type.
*/
/**
* Specifies the type of a comment.
* @enum {string}
*/
export const CommentType: Readonly<{
/** A blog post. */
blogPost: "blog-post";
/** A blog comment. */
comment: "comment";
/** A contact form or feedback form submission. */
contactForm: "contact-form";
/** A top-level forum post. */
forumPost: "forum-post";
/** A message sent between just a few users. */
message: "message";
/** A reply to a top-level forum post. */
reply: "reply";
/** A new user account. */
signup: "signup";
}>;
/**
* Defines the options of a {@link Comment } instance.
*/
export type CommentOptions = {
export interface CommentOptions {
/**
* The comment's author.
*/
author?: Author | null | undefined;
author: Author | null;
/**
* The comment's content.
*/
content?: string | undefined;
content: string;
/**
* The context in which this comment was posted.
*/
context: string[];
/**
* The UTC timestamp of the creation of the comment.
*/
date?: Date | null | undefined;
date: Date | null;
/**
* The permanent location of the entry the comment is submitted to.
*/
permalink?: string | undefined;
permalink: string;
/**
* The UTC timestamp of the publication time for the post, page or thread on which the comment was posted.
*/
postModified?: Date | null | undefined;
postModified: Date | null;
/**
* A string describing why the content is being rechecked.
*/
recheckReason?: string | undefined;
recheckReason: string;
/**
* The URL of the webpage that linked to the entry being requested.
*/
referrer?: string | undefined;
referrer: string;
/**
* The comment's type.
*/
type?: string | undefined;
};
import { Author } from "./author.js";
type: CommentType | string;
}
/**
* Specifies the type of a comment.
*/
export declare enum CommentType {
/**
* A blog post.
*/
blogPost = "blog-post",
/**
* A blog comment.
*/
comment = "comment",
/**
* A contact form or feedback form submission.
*/
contactForm = "contact-form",
/**
* A top-level forum post.
*/
forumPost = "forum-post",
/**
* A message sent between just a few users.
*/
message = "message",
/**
* A reply to a top-level forum post.
*/
reply = "reply",
/**
* A new user account.
*/
signup = "signup"
}
//# sourceMappingURL=comment.d.ts.map

@@ -6,2 +6,3 @@ export * from "./author.js";

export * from "./comment.js";
export * from "./usage.js";
//# sourceMappingURL=index.d.ts.map
# MIT License
Copyright &copy; 2014-2023 Cédric Belin
Copyright (c) Cédric Belin

@@ -4,0 +4,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -7,5 +7,5 @@ {

"name": "@cedx/akismet",
"repository": "github:cedx/akismet.js",
"repository": "cedx/akismet.js",
"type": "module",
"version": "16.0.2",
"version": "16.1.0",
"author": {

@@ -17,21 +17,15 @@ "email": "cedric@belin.io",

"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"@types/gulp": "^4.0.10",
"@types/node": "^18.11.18",
"c8": "^7.12.0",
"del": "^7.0.0",
"eslint": "^8.31.0",
"execa": "^6.1.0",
"gulp": "^4.0.2",
"gulp-replace": "^1.1.4",
"typedoc": "^0.23.24",
"typescript": "^4.9.4"
"@types/node": "^20.11.6",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"eslint": "^8.56.0",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
},
"exports": {
"types": "./lib/index.d.ts",
"import": "./src/index.js"
"import": "./lib/index.js"
},

@@ -42,2 +36,8 @@ "files": [

],
"imports": {
"#akismet": {
"types": "./lib/index.d.ts",
"import": "./lib/index.js"
}
},
"keywords": [

@@ -52,5 +52,11 @@ "akismet",

"scripts": {
"prepack": "gulp",
"test": "c8 --all --include=src/**/*.js --report-dir=var --reporter=lcovonly node --test"
"build": "node tool/build.js && tsc --project src/tsconfig.json",
"clean": "node tool/clean.js",
"doc": "typedoc --options etc/typedoc.js && node tool/doc.js",
"dist": "npm run clean && npm run build",
"lint": "tsc --project tsconfig.json && eslint --config=etc/eslint.cjs example src test tool",
"postpublish": "node tool/publish.js",
"prepack": "npm run dist",
"test": "npm run build && node --test --test-reporter=spec"
}
}
# Akismet for JS
![Runtime](https://badgen.net/npm/node/@cedx/akismet) ![Release](https://badgen.net/npm/v/@cedx/akismet) ![License](https://badgen.net/npm/license/@cedx/akismet) ![Downloads](https://badgen.net/npm/dt/@cedx/akismet) ![Coverage](https://badgen.net/codecov/c/github/cedx/akismet.js)
![Node.js](https://badgen.net/npm/node/@cedx/akismet) ![npm](https://badgen.net/npm/v/@cedx/akismet) ![License](https://badgen.net/npm/license/@cedx/akismet) ![Downloads](https://badgen.net/npm/dt/@cedx/akismet)

@@ -7,4 +7,4 @@ Prevent comment spam using [Akismet](https://akismet.com) service, in [JavaScript](https://developer.mozilla.org/docs/Web/JavaScript).

## Documentation
- [User guide](https://github.com/cedx/akismet.js/wiki)
- [API reference](https://cedx.github.io/akismet.js)
- [User guide](https://cedx.github.io/akismet.js)
- [API reference](https://cedx.github.io/akismet.js/api)

@@ -11,0 +11,0 @@ ## Development

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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