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

@noveo/dual-rpc-ws

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@noveo/dual-rpc-ws - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

119

build/common.d.ts

@@ -13,54 +13,63 @@ /**

export declare type JSONValue = object | [] | string | number | boolean | null;
interface RPCConnect {
type: MessageType.Connect;
jsonrpc: '2.0';
id: Id;
method: 'connect';
params: {
id?: Id;
result?: boolean;
};
declare namespace RPCMessages {
/**
* Special request for establishing the connection
*/
interface RPCConnect {
type: MessageType.Connect;
jsonrpc: '2.0';
id: Id;
method: 'connect';
params: {
id?: Id;
result?: boolean;
};
}
/**
* An error, if the sender rpc-call ended unexpectedly
* @internal
*/
interface RPCError {
type: MessageType.Error;
jsonrpc: '2.0';
id: Id;
error: string;
}
/**
* Malformed message
* @internal
*/
interface RPCMalformed {
type: MessageType.Malformed;
}
/**
* Method params. Library supports only one argument for the method and it
* must be an object (record with the different type which can be described
* by the json object)
* @internal
*/
interface RPCRequest {
type: MessageType.Request;
jsonrpc: '2.0';
id: Id;
method: Name;
params: Record<string, any>;
}
/**
* Result of the method execution. And json type
* @internal
*/
interface RPCResponse {
type: MessageType.Response;
jsonrpc: '2.0';
id: Id;
result: JSONValue;
}
/**
* Common structure of the JSON-RPC 2.0 message
* @internal
*/
type RPCMessageType = RPCMessages.RPCConnect | RPCMessages.RPCError | RPCMessages.RPCMalformed | RPCMessages.RPCRequest | RPCMessages.RPCResponse;
}
/**
* An error, if the sender rpc-call ended unexpectedly
*/
interface RPCError {
type: MessageType.Error;
jsonrpc: '2.0';
id: Id;
error: string;
}
/**
* Malformed message
*/
interface RPCMalformed {
type: MessageType.Malformed;
}
/**
* Method params. Library supports only one argument for the method and it
* must be an object (record with the different type which can be described
* by the json object)
*/
interface RPCRequest {
type: MessageType.Request;
jsonrpc: '2.0';
id: Id;
method: Name;
params: Record<string, any>;
}
/**
* Result of the method execution. And json type
*/
interface RPCResponse {
type: MessageType.Response;
jsonrpc: '2.0';
id: Id;
result: JSONValue;
}
/**
* Common structure of the JSON-RPC 2.0 message
* @internal
*/
declare type RPCMessageType = RPCConnect | RPCError | RPCMalformed | RPCRequest | RPCResponse;
/**
* A default context object. Every local RPC call have an object

@@ -107,3 +116,3 @@ */

*/
export declare function getMessage(data: string): RPCMessageType;
export declare function getMessage(data: string): RPCMessages.RPCMessageType;
interface RequestParams {

@@ -127,5 +136,7 @@ timeout: number;

}
export declare function rpcRequest(method: Name, params: any, id: Id): string;
export declare function rpcResponse(result: any, id: Id): string;
export declare function rpcError(error: any, id: Id): string;
export declare namespace RPCHelpers {
function rpcRequest(method: Name, params: any, id: Id): string;
function rpcResponse(result: any, id: Id): string;
function rpcError(error: any, id: Id): string;
}
export {};

@@ -105,32 +105,35 @@ "use strict";

exports.Request = Request;
function rpcRequest(method, params, id) {
return JSON.stringify({
jsonrpc: '2.0',
method,
params,
id,
});
}
exports.rpcRequest = rpcRequest;
function rpcResponse(result = null, id) {
console.log(JSON.stringify({
jsonrpc: '2.0',
result,
id,
}));
return JSON.stringify({
jsonrpc: '2.0',
result,
id,
});
}
exports.rpcResponse = rpcResponse;
function rpcError(error, id) {
return JSON.stringify({
jsonrpc: '2.0',
error,
id,
});
}
exports.rpcError = rpcError;
var RPCHelpers;
(function (RPCHelpers) {
function rpcRequest(method, params, id) {
return JSON.stringify({
jsonrpc: '2.0',
method,
params,
id,
});
}
RPCHelpers.rpcRequest = rpcRequest;
function rpcResponse(result = null, id) {
console.log(JSON.stringify({
jsonrpc: '2.0',
result,
id,
}));
return JSON.stringify({
jsonrpc: '2.0',
result,
id,
});
}
RPCHelpers.rpcResponse = rpcResponse;
function rpcError(error, id) {
return JSON.stringify({
jsonrpc: '2.0',
error,
id,
});
}
RPCHelpers.rpcError = rpcError;
})(RPCHelpers = exports.RPCHelpers || (exports.RPCHelpers = {}));
//# sourceMappingURL=common.js.map

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

let result = await this.handshake(message.params.id, ws);
ws.send(common_1.rpcRequest('connect', { result }, message.id));
ws.send(common_1.RPCHelpers.rpcRequest('connect', { result }, message.id));
if (!result) {

@@ -97,3 +97,3 @@ ws.close();

if (!method) {
return ws.send(common_1.rpcError(`Procedure not found.`, message.id));
return ws.send(common_1.RPCHelpers.rpcError(`Procedure not found.`, message.id));
}

@@ -106,6 +106,6 @@ try {

}), message.params);
ws.send(common_1.rpcResponse(result, message.id));
ws.send(common_1.RPCHelpers.rpcResponse(result, message.id));
}
catch (error) {
ws.send(common_1.rpcError(error.message, message.id));
ws.send(common_1.RPCHelpers.rpcError(error.message, message.id));
}

@@ -174,3 +174,3 @@ finally {

this.requests.set(id, request);
device.send(common_1.rpcRequest(method, params !== null && params !== void 0 ? params : null, id));
device.send(common_1.RPCHelpers.rpcRequest(method, params !== null && params !== void 0 ? params : null, id));
});

@@ -177,0 +177,0 @@ }

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

this.addEventListener('open', () => {
this.send(common_1.rpcRequest('connect', { id: params.token }, react_native_uuid_1.v4()));
this.send(common_1.RPCHelpers.rpcRequest('connect', { id: params.token }, react_native_uuid_1.v4()));
});

@@ -82,10 +82,10 @@ this.addEventListener('message', (event) => __awaiter(this, void 0, void 0, function* () {

if (!method) {
return this.send(common_1.rpcError(`Procedure not found.`, message.id));
return this.send(common_1.RPCHelpers.rpcError(`Procedure not found.`, message.id));
}
try {
const result = yield method.call(this, message.params, this.prepareContext({ id: message.id }));
this.send(common_1.rpcResponse(result, message.id));
this.send(common_1.RPCHelpers.rpcResponse(result, message.id));
}
catch (error) {
this.send(common_1.rpcError(error.message, message.id));
this.send(common_1.RPCHelpers.rpcError(error.message, message.id));
}

@@ -130,3 +130,3 @@ break;

this.requests.set(id, request);
this.send(common_1.rpcRequest(method, params !== null && params !== void 0 ? params : null, id));
this.send(common_1.RPCHelpers.rpcRequest(method, params !== null && params !== void 0 ? params : null, id));
});

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

@@ -13,54 +13,63 @@ /**

export declare type JSONValue = object | [] | string | number | boolean | null;
interface RPCConnect {
type: MessageType.Connect;
jsonrpc: '2.0';
id: Id;
method: 'connect';
params: {
id?: Id;
result?: boolean;
};
declare namespace RPCMessages {
/**
* Special request for establishing the connection
*/
interface RPCConnect {
type: MessageType.Connect;
jsonrpc: '2.0';
id: Id;
method: 'connect';
params: {
id?: Id;
result?: boolean;
};
}
/**
* An error, if the sender rpc-call ended unexpectedly
* @internal
*/
interface RPCError {
type: MessageType.Error;
jsonrpc: '2.0';
id: Id;
error: string;
}
/**
* Malformed message
* @internal
*/
interface RPCMalformed {
type: MessageType.Malformed;
}
/**
* Method params. Library supports only one argument for the method and it
* must be an object (record with the different type which can be described
* by the json object)
* @internal
*/
interface RPCRequest {
type: MessageType.Request;
jsonrpc: '2.0';
id: Id;
method: Name;
params: Record<string, any>;
}
/**
* Result of the method execution. And json type
* @internal
*/
interface RPCResponse {
type: MessageType.Response;
jsonrpc: '2.0';
id: Id;
result: JSONValue;
}
/**
* Common structure of the JSON-RPC 2.0 message
* @internal
*/
type RPCMessageType = RPCMessages.RPCConnect | RPCMessages.RPCError | RPCMessages.RPCMalformed | RPCMessages.RPCRequest | RPCMessages.RPCResponse;
}
/**
* An error, if the sender rpc-call ended unexpectedly
*/
interface RPCError {
type: MessageType.Error;
jsonrpc: '2.0';
id: Id;
error: string;
}
/**
* Malformed message
*/
interface RPCMalformed {
type: MessageType.Malformed;
}
/**
* Method params. Library supports only one argument for the method and it
* must be an object (record with the different type which can be described
* by the json object)
*/
interface RPCRequest {
type: MessageType.Request;
jsonrpc: '2.0';
id: Id;
method: Name;
params: Record<string, any>;
}
/**
* Result of the method execution. And json type
*/
interface RPCResponse {
type: MessageType.Response;
jsonrpc: '2.0';
id: Id;
result: JSONValue;
}
/**
* Common structure of the JSON-RPC 2.0 message
* @internal
*/
declare type RPCMessageType = RPCConnect | RPCError | RPCMalformed | RPCRequest | RPCResponse;
/**
* A default context object. Every local RPC call have an object

@@ -107,3 +116,3 @@ */

*/
export declare function getMessage(data: string): RPCMessageType;
export declare function getMessage(data: string): RPCMessages.RPCMessageType;
interface RequestParams {

@@ -127,5 +136,7 @@ timeout: number;

}
export declare function rpcRequest(method: Name, params: any, id: Id): string;
export declare function rpcResponse(result: any, id: Id): string;
export declare function rpcError(error: any, id: Id): string;
export declare namespace RPCHelpers {
function rpcRequest(method: Name, params: any, id: Id): string;
function rpcResponse(result: any, id: Id): string;
function rpcError(error: any, id: Id): string;
}
export {};

@@ -105,32 +105,35 @@ "use strict";

exports.Request = Request;
function rpcRequest(method, params, id) {
return JSON.stringify({
jsonrpc: '2.0',
method,
params,
id,
});
}
exports.rpcRequest = rpcRequest;
function rpcResponse(result = null, id) {
console.log(JSON.stringify({
jsonrpc: '2.0',
result,
id,
}));
return JSON.stringify({
jsonrpc: '2.0',
result,
id,
});
}
exports.rpcResponse = rpcResponse;
function rpcError(error, id) {
return JSON.stringify({
jsonrpc: '2.0',
error,
id,
});
}
exports.rpcError = rpcError;
var RPCHelpers;
(function (RPCHelpers) {
function rpcRequest(method, params, id) {
return JSON.stringify({
jsonrpc: '2.0',
method,
params,
id,
});
}
RPCHelpers.rpcRequest = rpcRequest;
function rpcResponse(result = null, id) {
console.log(JSON.stringify({
jsonrpc: '2.0',
result,
id,
}));
return JSON.stringify({
jsonrpc: '2.0',
result,
id,
});
}
RPCHelpers.rpcResponse = rpcResponse;
function rpcError(error, id) {
return JSON.stringify({
jsonrpc: '2.0',
error,
id,
});
}
RPCHelpers.rpcError = rpcError;
})(RPCHelpers = exports.RPCHelpers || (exports.RPCHelpers = {}));
//# sourceMappingURL=common.js.map
{
"name": "@noveo/dual-rpc-ws",
"version": "0.0.19",
"version": "0.0.20",
"description": "Remote procedure call",

@@ -5,0 +5,0 @@ "types": "build/index.d.ts",

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