New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@therms/rpc-server

Package Overview
Dependencies
Maintainers
2
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@therms/rpc-server - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

7

CHANGELOG.md

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

# [1.6.0](http://bitbucket.org/thermsio/rpc-server-ts/compare/v1.5.1...v1.6.0) (2021-04-25)
### Features
* add AJV validation to HandlerRegistrationInfo args ([06e35eb](http://bitbucket.org/thermsio/rpc-server-ts/commits/06e35eb7df8b58f8adaa8c7821a69bba38589c98))
## [1.5.1](http://bitbucket.org/thermsio/rpc-server-ts/compare/v1.5.0...v1.5.1) (2021-04-25)

@@ -2,0 +9,0 @@

1

dist/CallRequest.d.ts

@@ -36,2 +36,3 @@ export declare const DEFAULT_REQUEST_SCOPE = "global";

trace: {
[key: string]: any;
id: string;

@@ -38,0 +39,0 @@ };

import { CallRequest } from './CallRequest';
import { CallResponse } from './CallResponse';
export declare type Handler = (request: CallRequest) => Promise<CallResponse> | CallResponse;
export declare type HandlerRequestValidator = (request: CallRequest) => Promise<CallResponse | undefined> | CallResponse | undefined;
export interface HandlerRegistrationInfo {

@@ -8,2 +9,3 @@ args?: any;

description?: string;
private?: boolean;
procedure: string;

@@ -10,0 +12,0 @@ scope: string;

@@ -6,2 +6,3 @@ 'use strict';

var ObjectId = require('bson-objectid');
var Ajv = require('ajv');
var Debug = require('debug');

@@ -19,2 +20,3 @@ var amqp = require('amqp-connection-manager');

var ObjectId__default = /*#__PURE__*/_interopDefaultLegacy(ObjectId);
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
var Debug__default = /*#__PURE__*/_interopDefaultLegacy(Debug);

@@ -206,2 +208,7 @@ var amqp__default = /*#__PURE__*/_interopDefaultLegacy(amqp);

var ajv = new Ajv__default['default']({
coerceTypes: 'array',
removeAdditional: true,
useDefaults: true,
});
var debug$5 = Debug__default['default']('rpc:LocalHandlerManager');

@@ -212,2 +219,3 @@ var LocalHandlerManager = (function () {

this.handlersByHandlerRequestKey = {};
this.handlerRequestValidationsByHandlerRequestKey = {};
this.checkCanHandleRequest = function (request) {

@@ -231,2 +239,4 @@ return !!_this.handlersByHandlerRequestKey[makeHandlerRequestKey(request)];

catch (e) {
if (e instanceof CallResponse)
return [2, e];
return [2, new CallResponse({

@@ -241,4 +251,21 @@ code: 500,

this.registerHandler = function (request, handler) {
var _a;
debug$5('registerHandler', request);
_this.handlersByHandlerRequestKey[makeHandlerRequestKey(request)] = handler;
var key = makeHandlerRequestKey(request);
_this.handlersByHandlerRequestKey[key] = handler;
if (typeof request.args === 'object' && ((_a = request.args) === null || _a === void 0 ? void 0 : _a.type)) {
var validate_1 = ajv.compile(request.args);
_this.handlerRequestValidationsByHandlerRequestKey[key] = function (request) {
var valid = validate_1(request.args);
if (!valid) {
throw new CallResponse({
code: 422,
data: validate_1.errors,
message: 'args validation failed',
success: false,
}, request);
}
return undefined;
};
}
};

@@ -245,0 +272,0 @@ }

7

dist/RPCServer/CallManager/intrinsic/LocalHandlerManager.d.ts
import { CallRequest, ICallRequestDescription } from '../../../CallRequest';
import { Handler } from '../../../Handler';
import { Handler, HandlerRegistrationInfo } from '../../../Handler';
import { CallResponse } from '../../../CallResponse';
export interface LocalHandlerManager {
checkCanHandleRequest(request: ICallRequestDescription): boolean;
registerHandler(request: ICallRequestDescription, handler: Handler): void;
registerHandler(request: HandlerRegistrationInfo, handler: Handler): void;
}
export declare class LocalHandlerManager {
private handlersByHandlerRequestKey;
private handlerRequestValidationsByHandlerRequestKey;
checkCanHandleRequest: (request: ICallRequestDescription) => boolean;
getSimilarRegisteredProcedures: (request: ICallRequestDescription) => string;
manageRequest: (request: CallRequest) => Promise<CallResponse>;
registerHandler: (request: ICallRequestDescription, handler: Handler) => void;
registerHandler: (request: HandlerRegistrationInfo, handler: Handler) => void;
}
//# sourceMappingURL=LocalHandlerManager.d.ts.map
{
"name": "@therms/rpc-server",
"version": "1.5.1",
"version": "1.6.0",
"description": "RPC framework, Node.js lib",

@@ -56,2 +56,3 @@ "private": false,

"@types/koa-logger": "^3.1.1",
"ajv": "^8.1.0",
"amqp-connection-manager": "^3.2.2",

@@ -58,0 +59,0 @@ "amqplib": "^0.7.1",

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