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

wordpress-jwt-auth

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wordpress-jwt-auth - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

CHANGELOG.md

5

dist/Index.d.ts

@@ -24,3 +24,3 @@ /**

* Authenticate user
* @param host - hot URL
* @param host - host URL
* @param username - user's name used to login

@@ -33,2 +33,4 @@ * @param password - user's password used to login

* Validate token
* @param host - host URL
* @param token - token to validate
* @returns true if token is successfully validated

@@ -40,2 +42,3 @@ */

* @param host - url to wordpress
* @throws {CannotConnect}
*/

@@ -42,0 +45,0 @@ export declare const connectToJwt: (host: string) => Promise<{

52

dist/Index.js

@@ -43,3 +43,3 @@ "use strict";

* Authenticate user
* @param host - hot URL
* @param host - host URL
* @param username - user's name used to login

@@ -58,4 +58,5 @@ * @param password - user's password used to login

response = _a.sent();
if (!response.data.token) {
throw new Error('CannotAuthenticate: bad username or password');
switch (response.status) {
case 403: throw new Error('CannotAuthenticate: Bad username or password');
case 404: throw new Error("CannotAuthenticate: Page doesn't exists, make sure JWT is installed");
}

@@ -68,2 +69,4 @@ return [2 /*return*/, response.data];

* Validate token
* @param host - host URL
* @param token - token to validate
* @returns true if token is successfully validated

@@ -91,24 +94,33 @@ */

* @param host - url to wordpress
* @throws {CannotConnect}
*/
exports.connectToJwt = function (host) { return __awaiter(_this, void 0, void 0, function () {
var response;
return __generator(this, function (_a) {
// try to connect
return [2 /*return*/, {
/**
* Authenticate user
* @param host - hot URL
* @param username - user's name used to login
* @param password - user's password used to login
* @throws {CannotAuthenticate}
*/
generateToken: function (username, password) { return exports.generateToken(host, username, password); },
/**
* Validate token
* @param token - token to validate
* @returns true if token is successfully validated
*/
validateToken: function (token) { return exports.validateToken(host, token); },
}];
switch (_a.label) {
case 0: return [4 /*yield*/, axios_1.default.post(host + "/" + JWT_ENDPOINT + "/token")];
case 1:
response = _a.sent();
if (response.status === 404) {
throw new Error('CannotConnect: bad host or JWT is not installed');
}
return [2 /*return*/, {
/**
* Authenticate user
* @param host - host URL
* @param username - user's name used to login
* @param password - user's password used to login
* @throws {CannotAuthenticate}
*/
generateToken: function (username, password) { return exports.generateToken(host, username, password); },
/**
* Validate token
* @param token - token to validate
* @returns true if token is successfully validated
*/
validateToken: function (token) { return exports.validateToken(host, token); },
}];
}
});
}); };
//# sourceMappingURL=Index.js.map

@@ -32,3 +32,3 @@ import axios from 'axios';

* Authenticate user
* @param host - hot URL
* @param host - host URL
* @param username - user's name used to login

@@ -41,5 +41,7 @@ * @param password - user's password used to login

const response = await axios.post(endPoint + 'token', { username, password });
if (!response.data.token) {
throw new Error('CannotAuthenticate: bad username or password');
switch (response.status) {
case 403: throw new Error('CannotAuthenticate: Bad username or password');
case 404: throw new Error(`CannotAuthenticate: Page doesn\'t exists, make sure JWT is installed`);
}
return response.data as JWT;

@@ -50,2 +52,4 @@ };

* Validate token
* @param host - host URL
* @param token - token to validate
* @returns true if token is successfully validated

@@ -66,9 +70,14 @@ */

* @param host - url to wordpress
* @throws {CannotConnect}
*/
export const connectToJwt = async (host: string) => {
// try to connect
const response = await axios.post(`${host}/${JWT_ENDPOINT}/token`);
if (response.status === 404) {
throw new Error('CannotConnect: bad host or JWT is not installed');
}
return {
/**
* Authenticate user
* @param host - hot URL
* @param host - host URL
* @param username - user's name used to login

@@ -75,0 +84,0 @@ * @param password - user's password used to login

{
"name": "wordpress-jwt-auth",
"version": "1.1.0",
"version": "1.1.1",
"description": "Wordpress JWT authentication",

@@ -5,0 +5,0 @@ "main": "dist/Index.js",

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