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

@nodescript/protocomm

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodescript/protocomm - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

5

out/main/domain.d.ts

@@ -30,2 +30,7 @@ import { ObjectPropsDef } from '@nodescript/schema';

export type MethodType = 'query' | 'command';
export interface DomainMethodStat {
domain: string;
method: string;
latency: number;
}
export {};

3

out/main/rpc-handler.d.ts

@@ -0,1 +1,3 @@

import { Event } from '@nodescript/event';
import { DomainMethodStat } from './domain.js';
import { ProtocolIndex } from './protocol.js';

@@ -11,2 +13,3 @@ import { RpcEvent, RpcMethodRequest, RpcMethodResponse } from './rpc-messages.js';

readonly sendEvent: (evt: RpcEvent) => void;
methodStats: Event<DomainMethodStat>;
constructor(protocolIndex: ProtocolIndex<P>, protocolImpl: P, sendResponse: (res: RpcMethodResponse) => void, sendEvent: (evt: RpcEvent) => void);

@@ -13,0 +16,0 @@ processMessage(msg: unknown): Promise<void>;

30

out/main/rpc-handler.js

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

import { Event } from '@nodescript/event';
import { ChannelEvent } from './channel-event.js';

@@ -13,2 +14,3 @@ import { MethodNotFound } from './protocol.js';

this.sendEvent = sendEvent;
this.methodStats = new Event();
this.registerEvents();

@@ -40,12 +42,22 @@ }

async runMethod(rpcReq) {
const { domain, method, params } = rpcReq;
const { reqSchema, resSchema, } = this.protocolIndex.lookupMethod(domain, method);
const domainImpl = this.protocolImpl[domain];
const methodImpl = domainImpl?.[method];
if (!methodImpl) {
throw new MethodNotFound(`${domain}.${method}`);
const startedAt = Date.now();
try {
const { domain, method, params } = rpcReq;
const { reqSchema, resSchema, } = this.protocolIndex.lookupMethod(domain, method);
const domainImpl = this.protocolImpl[domain];
const methodImpl = domainImpl?.[method];
if (!methodImpl) {
throw new MethodNotFound(`${domain}.${method}`);
}
const decodedParams = reqSchema.decode(params, { strictRequired: true });
const res = await methodImpl.call(domainImpl, decodedParams);
return resSchema.decode(res);
}
const decodedParams = reqSchema.decode(params, { strictRequired: true });
const res = await methodImpl.call(domainImpl, decodedParams);
return resSchema.decode(res);
finally {
this.methodStats.emit({
domain: rpcReq.domain,
method: rpcReq.method,
latency: Date.now() - startedAt,
});
}
}

@@ -52,0 +64,0 @@ registerEvents() {

{
"name": "@nodescript/protocomm",
"version": "0.5.2",
"version": "0.5.3",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Bi-directional transport-agnostic JSON-based messaging",

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