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 3.0.3 to 3.1.0

dist/default-login-routes.d.ts

1

dist/Actions/ErrorAction.d.ts

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

* Action for unhandled (500) errors
* Returns a serialized error instance in JSON format.
*/

@@ -9,0 +10,0 @@ export declare class ErrorAction implements IRequestAction {

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

* Action for unhandled (500) errors
* Returns a serialized error instance in JSON format.
*/

@@ -11,0 +12,0 @@ let ErrorAction = class ErrorAction {

@@ -8,2 +8,4 @@ /// <reference types="node" />

* Action that logs in the current user
* Should be called with a JSON Post body with ``username`` and ``password`` fields.
* Returns the current user instance
*/

@@ -10,0 +12,0 @@ export declare class LoginAction implements IRequestAction {

@@ -10,2 +10,4 @@ "use strict";

* Action that logs in the current user
* Should be called with a JSON Post body with ``username`` and ``password`` fields.
* Returns the current user instance
*/

@@ -12,0 +14,0 @@ let LoginAction = class LoginAction {

4

dist/HttpAuthenticationSettings.js

@@ -17,4 +17,4 @@ "use strict";

this.model = core_1.User;
this.getUserStore = () => new core_1.InMemoryStore({ model: this.model, primaryKey: 'username' });
this.getSessionStore = () => new core_1.InMemoryStore({ model: DefaultSession_1.DefaultSession, primaryKey: 'sessionId' });
this.getUserStore = sm => sm.getStoreFor(core_1.User);
this.getSessionStore = sm => sm.getStoreFor(DefaultSession_1.DefaultSession);
this.cookieName = 'fss';

@@ -21,0 +21,0 @@ this.hashMethod = plain => hash_js_1.sha256()

@@ -13,3 +13,3 @@ /// <reference types="node" />

export interface HttpExtendedInjector extends Injector {
useHttpAuthentication: <TUser extends User>(settings: Partial<HttpAuthenticationSettings<TUser>>) => HttpExtendedInjector;
useHttpAuthentication: <TUser extends User>(settings?: Partial<HttpAuthenticationSettings<TUser>>) => HttpExtendedInjector;
addHttpRouting: (route: (incomingMessage: IncomingMessage) => Constructable<IRequestAction> | undefined) => HttpExtendedInjector;

@@ -16,0 +16,0 @@ useDefaultLoginRoutes: () => HttpExtendedInjector;

@@ -7,6 +7,7 @@ "use strict";

const https_1 = require("https");
const url_1 = require("url");
const _1 = require(".");
const default_login_routes_1 = require("./default-login-routes");
const HttpApi_1 = require("./HttpApi");
const HttpApiSettings_1 = require("./HttpApiSettings");
const DefaultSession_1 = require("./Models/DefaultSession");
Injector_1.Injector.prototype.useHttpApi = function (settings) {

@@ -19,2 +20,6 @@ const logger = this.logger.withScope('@furystack/http-api/useHttpApi');

const xi = this;
// Setup default in memory stores for Users and Sessions
xi.setupStores(sm => sm
.addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }))
.addStore(new core_1.InMemoryStore({ model: DefaultSession_1.DefaultSession, primaryKey: 'sessionId' })));
xi.setExplicitInstance({ ...new HttpApiSettings_1.HttpApiSettings(), ...settings }, HttpApiSettings_1.HttpApiSettings);

@@ -53,14 +58,3 @@ xi.useHttpAuthentication = s => {

};
xi.useDefaultLoginRoutes = () => xi.addHttpRouting(msg => {
const urlPathName = url_1.parse(msg.url || '', true).pathname;
switch (urlPathName) {
case '/currentUser':
return _1.GetCurrentUser;
case '/login':
return _1.LoginAction;
case '/logout':
return _1.LogoutAction;
}
return undefined;
});
xi.useDefaultLoginRoutes = () => xi.addHttpRouting(default_login_routes_1.defaultLoginRoutes);
xi.getInstance(HttpApi_1.HttpApi);

@@ -67,0 +61,0 @@ return xi;

@@ -5,5 +5,11 @@ /**

export declare class DefaultSession {
/**
* The generated session identifier
*/
sessionId: string;
/**
* The user's login name for the session
*/
username: string;
}
//# sourceMappingURL=DefaultSession.d.ts.map

@@ -6,4 +6,8 @@ import { User } from '@furystack/core';

export interface IExternalLoginService<TUser extends User, TArgs extends any[]> {
/**
* Logs in the current user with the provided data
* @param args The arguments from the login service
*/
login(...args: TArgs): Promise<TUser>;
}
//# sourceMappingURL=IExternalLoginService.d.ts.map

@@ -6,4 +6,7 @@ import { Disposable } from '@sensenet/client-utils';

export interface IRequestAction extends Disposable {
/**
* The method will be executed for each request
*/
exec(): Promise<void>;
}
//# sourceMappingURL=IRequestAction.d.ts.map

@@ -8,3 +8,11 @@ /// <reference types="node" />

*/
export declare type IRouteModel = (incomingMessage: IncomingMessage, injector: Injector) => Constructable<IRequestAction> | undefined;
export declare type IRouteModel = (
/**
* The incoming request message
*/
incomingMessage: IncomingMessage,
/**
* The injector instance
*/
injector: Injector) => Constructable<IRequestAction> | undefined;
//# sourceMappingURL=IRouteModel.d.ts.map
{
"name": "@furystack/http-api",
"version": "3.0.3",
"version": "3.1.0",
"description": "HTTP Api FuryStack package",

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

"dependencies": {
"@furystack/core": "^4.0.3",
"@furystack/inject": "^3.0.3",
"@furystack/logging": "^1.1.2",
"@furystack/core": "^4.0.4",
"@furystack/inject": "^3.0.4",
"@furystack/logging": "^1.1.3",
"@sensenet/client-utils": "^1.5.1",

@@ -82,3 +82,3 @@ "@types/node": "^11.13.7",

"typings": "./dist/index.d.ts",
"gitHead": "d1948413d02be452fa90bea42fb54fe2bb73b687"
"gitHead": "91e5f8f4b00f214ed10de7fe237fa2731f5175e9"
}

@@ -8,2 +8,3 @@ import { Injectable } from '@furystack/inject'

* Action for unhandled (500) errors
* Returns a serialized error instance in JSON format.
*/

@@ -10,0 +11,0 @@ @Injectable({ lifetime: 'transient' })

@@ -9,2 +9,4 @@ import { Injectable } from '@furystack/inject'

* Action that logs in the current user
* Should be called with a JSON Post body with ``username`` and ``password`` fields.
* Returns the current user instance
*/

@@ -11,0 +13,0 @@ @Injectable({ lifetime: 'transient' })

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

import { InMemoryStore, IPhysicalStore, User } from '@furystack/core'
import { IPhysicalStore, User } from '@furystack/core'
import { StoreManager } from '@furystack/core/dist/StoreManager'

@@ -14,6 +14,8 @@ import { Constructable, Injectable } from '@furystack/inject'

public getUserStore: (storeManager: StoreManager) => IPhysicalStore<TUser> = () =>
new InMemoryStore<TUser>({ model: this.model, primaryKey: 'username' })
public getSessionStore: (storeManager: StoreManager) => IPhysicalStore<DefaultSession> = () =>
new InMemoryStore({ model: DefaultSession, primaryKey: 'sessionId' })
public getUserStore: (storeManager: StoreManager) => IPhysicalStore<TUser> = sm =>
sm.getStoreFor<TUser>(User as Constructable<TUser>)
public getSessionStore: (storeManager: StoreManager) => IPhysicalStore<DefaultSession> = sm =>
sm.getStoreFor(DefaultSession)
public cookieName: string = 'fss'

@@ -20,0 +22,0 @@ public hashMethod: (plain: string) => string = plain =>

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

import { ServerManager, User } from '@furystack/core'
import { ServerManager, User, InMemoryStore } from '@furystack/core'
import { Constructable } from '@furystack/inject'

@@ -7,6 +7,7 @@ import { Injector } from '@furystack/inject/dist/Injector'

import { createServer as createHttpsServer } from 'https'
import { parse } from 'url'
import { GetCurrentUser, HttpAuthenticationSettings, IRequestAction, LoginAction, LogoutAction } from '.'
import { HttpAuthenticationSettings, IRequestAction } from '.'
import { defaultLoginRoutes } from './default-login-routes'
import { HttpApi } from './HttpApi'
import { HttpApiSettings } from './HttpApiSettings'
import { DefaultSession } from './Models/DefaultSession'

@@ -18,3 +19,3 @@ /**

useHttpAuthentication: <TUser extends User>(
settings: Partial<HttpAuthenticationSettings<TUser>>,
settings?: Partial<HttpAuthenticationSettings<TUser>>,
) => HttpExtendedInjector

@@ -48,2 +49,10 @@ addHttpRouting: (

const xi = this as HttpExtendedInjector
// Setup default in memory stores for Users and Sessions
xi.setupStores(sm =>
sm
.addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
.addStore(new InMemoryStore({ model: DefaultSession, primaryKey: 'sessionId' })),
)
xi.setExplicitInstance({ ...new HttpApiSettings(), ...settings }, HttpApiSettings)

@@ -87,15 +96,3 @@ xi.useHttpAuthentication = s => {

xi.useDefaultLoginRoutes = () =>
xi.addHttpRouting(msg => {
const urlPathName = parse(msg.url || '', true).pathname
switch (urlPathName) {
case '/currentUser':
return GetCurrentUser
case '/login':
return LoginAction
case '/logout':
return LogoutAction
}
return undefined
})
xi.useDefaultLoginRoutes = () => xi.addHttpRouting(defaultLoginRoutes)

@@ -102,0 +99,0 @@ xi.getInstance(HttpApi)

@@ -5,4 +5,11 @@ /**

export class DefaultSession {
/**
* The generated session identifier
*/
public sessionId!: string
/**
* The user's login name for the session
*/
public username!: string
}

@@ -7,3 +7,7 @@ import { User } from '@furystack/core'

export interface IExternalLoginService<TUser extends User, TArgs extends any[]> {
/**
* Logs in the current user with the provided data
* @param args The arguments from the login service
*/
login(...args: TArgs): Promise<TUser>
}

@@ -7,3 +7,6 @@ import { Disposable } from '@sensenet/client-utils'

export interface IRequestAction extends Disposable {
/**
* The method will be executed for each request
*/
exec(): Promise<void>
}

@@ -9,4 +9,11 @@ import { Constructable, Injector } from '@furystack/inject'

export type IRouteModel = (
/**
* The incoming request message
*/
incomingMessage: IncomingMessage,
/**
* The injector instance
*/
injector: Injector,
) => Constructable<IRequestAction> | undefined

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

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

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