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

nodecommons-rest

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodecommons-rest - npm Package Compare versions

Comparing version 3.0.9 to 3.1.0

dist/apis/commons-rest-session.api.d.ts

15

dist/apis/commons-rest-user-session.api.d.ts

@@ -6,18 +6,7 @@ import { ICommonsSession } from 'tscommons-session';

import { CommonsRestServer } from '../servers/commons-rest.server';
import { TCommonsContentHandler } from '../types/tcommons-content-handler';
import { TCommonsNoContentHandler } from '../types/tcommons-no-content-handler';
import { CommonsRestApi } from './commons-rest.api';
export declare abstract class CommonsRestUserSessionApi<T extends ICommonsUser, S extends CommonsUserSessionService<T>> extends CommonsRestApi {
private sessionService;
import { CommonsRestSessionApi } from './commons-rest-session.api';
export declare abstract class CommonsRestUserSessionApi<T extends ICommonsUser, S extends CommonsUserSessionService<T>> extends CommonsRestSessionApi<T, S> {
constructor(restServer: CommonsRestServer, sessionService: S);
protected authenticate(user: T, _sessionService: S, _req: ICommonsRequestWithStrictParams): Promise<ICommonsSession<T> | undefined>;
installAuthentication(authenticateQuery: string, getUserByUsernameAndNamespace: (username: string, namespace?: string) => Promise<T | undefined>): void;
private wrapNoContentHandler;
private wrapContentHandler;
protected getSessionHandler(query: string, handler: TCommonsContentHandler): void;
protected postSessionHandler(query: string, handler: TCommonsContentHandler): void;
protected patchSessionHandler(query: string, handler: TCommonsNoContentHandler): void;
protected putSessionHandler(query: string, handler: TCommonsContentHandler): void;
protected deleteSessionHandler(query: string, handler: TCommonsNoContentHandler): void;
protected headSessionHandler(query: string, handler: TCommonsNoContentHandler): void;
}

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

const tscommons_core_1 = require("tscommons-core");
const commons_rest_session_api_1 = require("./commons-rest-session.api");
const commons_rest_api_1 = require("./commons-rest.api");
class CommonsRestUserSessionApi extends commons_rest_api_1.CommonsRestApi {
class CommonsRestUserSessionApi extends commons_rest_session_api_1.CommonsRestSessionApi {
constructor(restServer, sessionService) {
super(restServer);
this.sessionService = sessionService;
super(restServer, sessionService);
}

@@ -35,63 +35,5 @@ authenticate(user, _sessionService, _req) {

}));
this.deleteSessionHandler(`${authenticateQuery}`, (req, _res) => __awaiter(this, void 0, void 0, function* () {
this.sessionService.destroy(req.session);
}));
}
wrapNoContentHandler(handler) {
return (request, response) => __awaiter(this, void 0, void 0, function* () {
const authorization = request.get('Authorization');
if (authorization === undefined)
return commons_rest_api_1.CommonsRestApi.unauthorized('No authorization header supplied');
const regex = /^session (.+)$/;
const result = regex.exec(authorization);
if (result === null)
return commons_rest_api_1.CommonsRestApi.unauthorized('Invalid authorization header supplied');
const session = yield this.sessionService.validate(result[1]);
if (!session)
return commons_rest_api_1.CommonsRestApi.forbidden('Session ID is not accepted');
const typecast = request;
typecast.session = session;
return yield handler(request, response);
});
}
wrapContentHandler(handler) {
return (request, response) => __awaiter(this, void 0, void 0, function* () {
const authorization = request.get('Authorization');
if (authorization === undefined)
return commons_rest_api_1.CommonsRestApi.unauthorized('No authorization header supplied');
const regex = /^session (.+)$/;
const result = regex.exec(authorization);
if (result === null)
return commons_rest_api_1.CommonsRestApi.unauthorized('Invalid authorization header supplied');
const session = yield this.sessionService.validate(result[1]);
if (!session)
return commons_rest_api_1.CommonsRestApi.forbidden('Session ID is not accepted');
const typecast = request;
typecast.session = session;
return yield handler(request, response);
});
}
getSessionHandler(query, handler) {
super.getHandler(query, this.wrapContentHandler(handler));
}
// insert
postSessionHandler(query, handler) {
super.postHandler(query, this.wrapContentHandler(handler));
}
// update
patchSessionHandler(query, handler) {
super.patchHandler(query, this.wrapNoContentHandler(handler));
}
// upsert
putSessionHandler(query, handler) {
super.putHandler(query, this.wrapContentHandler(handler));
}
deleteSessionHandler(query, handler) {
super.deleteHandler(query, this.wrapNoContentHandler(handler));
}
headSessionHandler(query, handler) {
super.headHandler(query, this.wrapNoContentHandler(handler));
}
}
exports.CommonsRestUserSessionApi = CommonsRestUserSessionApi;
//# sourceMappingURL=commons-rest-user-session.api.js.map
export * from './commons-rest-key.api';
export * from './commons-rest-session.api';
export * from './commons-rest-user-pw-hash-session.api';

@@ -3,0 +4,0 @@ export * from './commons-rest-user-session.api';

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

__export(require("./commons-rest-key.api"));
__export(require("./commons-rest-session.api"));
__export(require("./commons-rest-user-pw-hash-session.api"));

@@ -10,0 +11,0 @@ __export(require("./commons-rest-user-session.api"));

{
"name": "nodecommons-rest",
"version": "3.0.9",
"version": "3.1.0",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

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