Socket
Socket
Sign inDemoInstall

protocat

Package Overview
Dependencies
35
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.3 to 0.6.4

dist/lib/server/reflection_run.d.ts

2

dist/lib/client/client.js

@@ -10,3 +10,3 @@ "use strict";

const rpc = grpcClient[rpcName];
const type = call_types_1.stubToType(rpc);
const type = (0, call_types_1.stubToType)(rpc);
const RequestType = rpc.requestType;

@@ -13,0 +13,0 @@ if (type === call_types_1.CallType.Unary) {

/// <reference types="node" />
import { EventEmitter } from 'events';
declare type KnownKeys<T> = ({
declare type KnownKeys<T> = {
[K in keyof T]: string extends K ? never : number extends K ? never : K;
} extends {
[_ in keyof T]: infer U;
} ? U : never) & keyof T;
} extends Record<any, infer X> ? X extends keyof T ? X : never : never;
declare type NeverKeys<T> = ({
[K in keyof T]: T[K] extends never ? never : K;
} extends {
[_ in keyof T]: infer U;
} ? U : never) & keyof T;
} extends Record<any, infer U> ? U : never) & keyof T;
export declare type RemoveIdxSgn<T> = Pick<T, KnownKeys<T>>;

@@ -14,0 +10,0 @@ export declare type OmitNeverKeys<T> = Pick<T, NeverKeys<T>>;

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

const methodHandlers = this.serviceHandlers[methodName]; // HandlerCS<any, any>[] | HandlerU<any, any>[] | HandlerBS<any, any>[] | HandlerSS<any, any>[]
const wrappedHandler = wrapToHandler(methodDefinition, compose_middleware_1.composeMiddleware([...this.middleware, ...methodHandlers]));
const type = call_types_1.stubToType(methodDefinition);
const wrappedHandler = wrapToHandler(methodDefinition, (0, compose_middleware_1.composeMiddleware)([...this.middleware, ...methodHandlers]));
const type = (0, call_types_1.stubToType)(methodDefinition);
this.server.register(methodDefinition.path, wrappedHandler, msg => msg instanceof Buffer ? msg : methodDefinition.responseSerialize(msg), methodDefinition.requestDeserialize, type);

@@ -58,3 +58,3 @@ }

this.registerHandlers();
await grpc_helpers_1.bindAsync(this.server, address, creds);
await (0, grpc_helpers_1.bindAsync)(this.server, address, creds);
this.server.start();

@@ -66,3 +66,3 @@ }

stop() {
return grpc_helpers_1.tryShutdown(this.server);
return (0, grpc_helpers_1.tryShutdown)(this.server);
}

@@ -78,3 +78,3 @@ }

const wrapToHandler = (methodDefinition, methodHandler) => {
const type = call_types_1.stubToType(methodDefinition);
const type = (0, call_types_1.stubToType)(methodDefinition);
const createContext = (call) => {

@@ -88,3 +88,3 @@ const initialMetadata = new grpc.Metadata();

path: methodDefinition.path,
...grpc_helpers_1.path2Fragments(methodDefinition.path),
...(0, grpc_helpers_1.path2Fragments)(methodDefinition.path),
flushInitialMetadata: () => call.sendMetadata(initialMetadata),

@@ -112,6 +112,6 @@ responseSerialize: methodDefinition.responseSerialize,

if (cb) {
cb(on_error_1.addMeta(e, call), null, call.trailingMetadata);
cb((0, on_error_1.addMeta)(e, call), null, call.trailingMetadata);
}
else {
grpcCall.emit('error', on_error_1.addMeta(e, call));
grpcCall.emit('error', (0, on_error_1.addMeta)(e, call));
}

@@ -118,0 +118,0 @@ }

import { Middleware, ProtoCatAnyCall } from '../call';
declare type ErrorHandler = (error: Error, call: ProtoCatAnyCall) => any;
declare type ErrorHandler = (error: unknown, call: ProtoCatAnyCall) => any;
export declare const addMeta: (e: any, call: ProtoCatAnyCall) => any;

@@ -4,0 +4,0 @@ /**

@@ -39,3 +39,3 @@ "use strict";

emitter.flushInitialMetadata();
exports.addMeta(e, emitter);
(0, exports.addMeta)(e, emitter);
originalEmit.apply(emitter, ['error', e]);

@@ -42,0 +42,0 @@ }

@@ -8,3 +8,2 @@ // package: cats.v1

import * as grpc from "@grpc/grpc-js";
import {handleClientStreamingCall} from "@grpc/grpc-js/build/src/server-call";
import * as v1_cat_pb from "../v1/cat_pb";

@@ -62,3 +61,3 @@ import * as type_cat_pb from "../type/cat_pb";

watchCats: grpc.handleServerStreamingCall<v1_cat_pb.WatchCatsRequest, type_cat_pb.Cat>;
shareLocation: handleClientStreamingCall<v1_cat_pb.ShareLocationRequest, v1_cat_pb.ShareLocationResponse>;
shareLocation: grpc.handleClientStreamingCall<v1_cat_pb.ShareLocationRequest, v1_cat_pb.ShareLocationResponse>;
feedCats: grpc.handleBidiStreamingCall<v1_cat_pb.FeedCatsRequest, type_cat_pb.Cat>;

@@ -65,0 +64,0 @@ }

@@ -8,3 +8,2 @@ // package: cats.v1

import * as grpc from "@grpc/grpc-js";
import {handleClientStreamingCall} from "@grpc/grpc-js/build/src/server-call";
import * as v1_hello_pb from "../v1/hello_pb";

@@ -61,3 +60,3 @@

serverStream: grpc.handleServerStreamingCall<v1_hello_pb.Hello, v1_hello_pb.Hello>;
clientStream: handleClientStreamingCall<v1_hello_pb.Hello, v1_hello_pb.Hello>;
clientStream: grpc.handleClientStreamingCall<v1_hello_pb.Hello, v1_hello_pb.Hello>;
bidi: grpc.handleBidiStreamingCall<v1_hello_pb.Hello, v1_hello_pb.Hello>;

@@ -64,0 +63,0 @@ }

@@ -58,10 +58,10 @@ "use strict";

});
await grpc_helpers_1.bindAsync(server, ADDR, grpc_js_1.ServerCredentials.createInsecure());
await (0, grpc_helpers_1.bindAsync)(server, ADDR, grpc_js_1.ServerCredentials.createInsecure());
server.start();
});
afterAll(() => grpc_helpers_1.tryShutdown(server));
const metadataInt = metadata_interceptor_1.metadataInterceptor((meta, opts) => {
afterAll(() => (0, grpc_helpers_1.tryShutdown)(server));
const metadataInt = (0, metadata_interceptor_1.metadataInterceptor)((meta, opts) => {
meta.set('path', opts.method_definition.path);
});
const alInt = access_log_interceptor_1.accessLogInterceptor(async (ctx, next) => {
const alInt = (0, access_log_interceptor_1.accessLogInterceptor)(async (ctx, next) => {
spyInterceptors(`${ctx.options.method_definition.path} -->`);

@@ -71,6 +71,6 @@ const st = await next();

});
const singleClient = client_1.createClient(hello_grpc_pb_1.GreetingClient, ADDR, grpc_js_1.ChannelCredentials.createInsecure(), {
const singleClient = (0, client_1.createClient)(hello_grpc_pb_1.GreetingClient, ADDR, grpc_js_1.ChannelCredentials.createInsecure(), {
interceptors: [metadataInt, alInt],
});
const nestedClient = client_1.createClient({ foo: hello_grpc_pb_1.GreetingClient }, ADDR, undefined, {
const nestedClient = (0, client_1.createClient)({ foo: hello_grpc_pb_1.GreetingClient }, ADDR, undefined, {
interceptors: [metadataInt, alInt],

@@ -77,0 +77,0 @@ });

@@ -50,3 +50,3 @@ "use strict";

for (const p of paths) {
expect(grpc_helpers_1.path2Fragments(p.path)).toMatchObject(p.expect);
expect((0, grpc_helpers_1.path2Fragments)(p.path)).toMatchObject(p.expect);
}

@@ -53,0 +53,0 @@ });

@@ -30,3 +30,3 @@ "use strict";

});
app.use(cache_1.createCache(cache, (call, hit, hash) => {
app.use((0, cache_1.createCache)(cache, (call, hit, hash) => {
call.initialMetadata.set('cache', hit ? 'hit' : 'miss');

@@ -38,3 +38,3 @@ call.initialMetadata.set('cache-key', hash);

describe('Caching', () => {
const client = client_1.createClient(hello_grpc_pb_1.GreetingClient, ADDR);
const client = (0, client_1.createClient)(hello_grpc_pb_1.GreetingClient, ADDR);
beforeEach(() => {

@@ -41,0 +41,0 @@ cache.set.mockClear();

@@ -10,3 +10,3 @@ "use strict";

let acc = '';
await compose_middleware_1.composeMiddleware(chain.split('').map((char) => async (call, next) => {
await (0, compose_middleware_1.composeMiddleware)(chain.split('').map((char) => async (call, next) => {
acc += char;

@@ -32,9 +32,9 @@ await new Promise(resolve => setTimeout(resolve, Math.random() * 5));

};
await compose_middleware_1.composeMiddleware([catcher, dud1, syncError, dud2])(null, null);
await (0, compose_middleware_1.composeMiddleware)([catcher, dud1, syncError, dud2])(null, null);
expect(dud1).toHaveBeenCalledTimes(1);
expect(dud2).toHaveBeenCalledTimes(0);
expect(lastErr).toBe('syncError');
await compose_middleware_1.composeMiddleware([catcher, asyncError])(null, null);
await (0, compose_middleware_1.composeMiddleware)([catcher, asyncError])(null, null);
expect(lastErr).toBe('asyncError');
await expect(compose_middleware_1.composeMiddleware([dud1, syncError])(null, null)).rejects.toThrow(/syncError/);
await expect((0, compose_middleware_1.composeMiddleware)([dud1, syncError])(null, null)).rejects.toThrow(/syncError/);
});

@@ -41,0 +41,0 @@ });

@@ -47,3 +47,3 @@ "use strict";

});
app.use(__1.onError((e, call) => {
app.use((0, __1.onError)((e, call) => {
call.initialMetadata.set('onerror', `${call.type}-onerror`);

@@ -50,0 +50,0 @@ call.trailingMetadata.set('onerror', `${call.type}-onerror`);

{
"name": "protocat",
"description": "Modern, minimalist type-safe gRPC framework for Node.js",
"version": "0.6.3",
"version": "0.6.4",
"author": "Jaroslav Šmolík <grissius@gmail.com>",

@@ -40,4 +40,4 @@ "main": "./dist/index.js",

"dependencies": {
"@grpc/grpc-js": "^1.3.2",
"@types/google-protobuf": "^3.15.2"
"@grpc/grpc-js": "^1.3.7",
"@types/google-protobuf": "^3.15.5"
},

@@ -48,5 +48,5 @@ "devDependencies": {

"codecov": "^3.8.2",
"google-protobuf": "^3.17.0",
"grpc-tools": "^1.11.1",
"grpc_tools_node_protoc_ts": "^5.2.2",
"google-protobuf": "^3.18.0",
"grpc-tools": "^1.11.2",
"grpc_tools_node_protoc_ts": "^5.3.2",
"husky": "^6.0.0",

@@ -59,4 +59,4 @@ "jest": "^26.6.3",

"typedoc-plugin-markdown": "^3.8.1",
"typescript": "^4.2.4"
"typescript": "^4.4.3"
}
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc