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

@furystack/http-api

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/http-api - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

8

dist/ActionDecorators/Authenticate.js

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@furystack/core");
exports.Authenticate = () => (constructor) => {

@@ -27,2 +28,9 @@ return class extends constructor {

serverResponse.end();
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({
scope: "@furystack/http-api/@Authenticate()",
message: `A Visitor user has been tried to access to action '${incomingMessage.url}' without authentication.`,
data: {
url: incomingMessage.url,
},
});
return;

@@ -29,0 +37,0 @@ }

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@furystack/core");
exports.Authorize = (...roles) => (constructor) => {

@@ -25,2 +26,11 @@ return class extends constructor {

serverResponse.end();
const currentUser = yield getContext().getCurrentUser();
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({
scope: "@furystack/http-api/@Authorize()",
message: `User '${currentUser.Username}' has been tried to access to action '${incomingMessage.url}' without the required roles.`,
data: {
user: currentUser,
roles,
},
});
return;

@@ -27,0 +37,0 @@ }

2

dist/ErrorAction.d.ts

@@ -7,5 +7,5 @@ /// <reference types="node" />

exec(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext): Promise<void>;
returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, _getContext: () => IContext, error: any): Promise<void>;
returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext, error: any): Promise<void>;
segmentName: string;
constructor();
}

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@furystack/core");
const RequestAction_1 = require("./RequestAction");

@@ -21,3 +22,3 @@ class ErrorAction extends RequestAction_1.RequestAction {

}
returnError(incomingMessage, serverResponse, _getContext, error) {
returnError(incomingMessage, serverResponse, getContext, error) {
return __awaiter(this, void 0, void 0, function* () {

@@ -27,2 +28,9 @@ serverResponse.writeHead(500, "Server error", { "Content-Type": "application/json" });

serverResponse.end();
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({
scope: "@furystack/http-api/ErrorAction",
message: `An action returned 500 from '${incomingMessage.url}'.`,
data: {
error,
},
});
});

@@ -29,0 +37,0 @@ }

{
"name": "@furystack/http-api",
"version": "0.4.2",
"version": "0.4.3",
"description": "HTTP Api FuryStack package",

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

@@ -1,2 +0,2 @@

import { Constructable, IContext } from "@furystack/core";
import { Constructable, IContext, LoggerCollection } from "@furystack/core";
import { IncomingMessage, ServerResponse } from "http";

@@ -18,2 +18,9 @@ import { IRequestAction } from "../Models/IRequestAction";

serverResponse.end();
getContext().getInjector().GetInstance(LoggerCollection).Warning({
scope: "@furystack/http-api/@Authenticate()",
message: `A Visitor user has been tried to access to action '${incomingMessage.url}' without authentication.`,
data: {
url: incomingMessage.url,
},
});
return;

@@ -20,0 +27,0 @@ }

@@ -1,2 +0,2 @@

import { Constructable, IContext, IRole } from "@furystack/core";
import { Constructable, IContext, IRole, LoggerCollection } from "@furystack/core";
import { IncomingMessage, ServerResponse } from "http";

@@ -14,2 +14,11 @@ import { IRequestAction } from "../Models/IRequestAction";

serverResponse.end();
const currentUser = await getContext().getCurrentUser();
getContext().getInjector().GetInstance(LoggerCollection).Warning({
scope: "@furystack/http-api/@Authorize()",
message: `User '${currentUser.Username}' has been tried to access to action '${incomingMessage.url}' without the required roles.`,
data: {
user: currentUser,
roles,
},
});
return;

@@ -16,0 +25,0 @@ }

@@ -1,2 +0,2 @@

import { IContext } from "@furystack/core";
import { IContext, LoggerCollection } from "@furystack/core";
import { IncomingMessage, ServerResponse } from "http";

@@ -10,3 +10,3 @@ import { Authorize } from "./ActionDecorators/Authorize";

}
public async returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, _getContext: () => IContext, error: any): Promise<void> {
public async returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext, error: any): Promise<void> {
serverResponse.writeHead(500, "Server error",

@@ -17,2 +17,9 @@ { "Content-Type": "application/json" },

serverResponse.end();
getContext().getInjector().GetInstance(LoggerCollection).Warning({
scope: "@furystack/http-api/ErrorAction",
message: `An action returned 500 from '${incomingMessage.url}'.`,
data: {
error,
},
});
}

@@ -19,0 +26,0 @@ public segmentName: string = "";

import { IContext } from "@furystack/core";
import { IncomingMessage, ServerResponse } from "http";
import { Authorize } from "./ActionDecorators/Authorize";
import { IRequestAction } from "./Models/IRequestAction";

@@ -5,0 +4,0 @@ import { RequestAction } from "./RequestAction";

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