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

@peerbit/rpc

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/rpc - npm Package Compare versions

Comparing version 3.0.25 to 4.0.0

7

lib/esm/controller.d.ts
import { AbstractType } from "@dao-xyz/borsh";
import { PublicSignKey } from "@peerbit/crypto";
import { RPCOptions, RPCResponse, PublishOptions } from "./io.js";
import { RPCResponse, EncryptionOptions, RPCRequestOptions } from "./io.js";
import { Program } from "@peerbit/program";
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
export type RPCSetupOptions<Q, R> = {

@@ -42,3 +43,3 @@ topic: string;

*/
send(message: Q, options?: PublishOptions): Promise<void>;
send(message: Q, options?: EncryptionOptions & WithMode & PriorityOptions): Promise<void>;
private createResponseHandler;

@@ -51,5 +52,5 @@ /**

*/
request(request: Q, options?: RPCOptions<R>): Promise<RPCResponse<R>[]>;
request(request: Q, options?: RPCRequestOptions<R>): Promise<RPCResponse<R>[]>;
get topic(): string;
getTopics(): string[];
}

@@ -113,2 +113,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

topics: [this.topic],
priority: message.header.priority, // send back with same priority. TODO, make this better in the future
/// TODO make redundancy parameter configurable?

@@ -169,2 +170,3 @@ mode: new SilentDelivery({

return {
priority: options?.priority,
mode: options?.mode,

@@ -171,0 +173,0 @@ topics: [this.topic]

import { X25519PublicKey, Ed25519PublicKey, PublicSignKey, X25519Keypair } from "@peerbit/crypto";
import { DeliveryMode } from "@peerbit/stream-interface";
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
export declare const logger: import("pino").Logger<never>;
export type RPCOptions<R> = {
export type RPCRequestResponseOptions<R> = {
amount?: number;

@@ -10,4 +10,5 @@ timeout?: number;

signal?: AbortSignal;
} & PublishOptions;
export type PublishOptions = {
};
export type RPCRequestOptions<R> = RPCRequestResponseOptions<R> & EncryptionOptions & WithMode & PriorityOptions;
export type EncryptionOptions = {
encryption?: {

@@ -17,4 +18,2 @@ key: X25519Keypair;

};
strict?: boolean;
mode?: DeliveryMode;
};

@@ -21,0 +20,0 @@ export type RPCResponse<R> = {

@@ -0,6 +1,11 @@

import { DeliveryMode, PriorityOptions } from "@peerbit/stream-interface";
import { RPC } from "./controller";
import { RPCOptions, RPCResponse } from "./io";
import { EncryptionOptions, RPCRequestResponseOptions, RPCResponse } from "./io";
import { Constructor } from "@dao-xyz/borsh";
export declare class MissingResponsesError extends Error {
constructor(message: string);
}
export declare const queryAll: <Q, R>(rpc: RPC<Q, R>, groups: string[][], request: Q, responseHandler: (response: RPCResponse<R>[]) => Promise<void> | void, options?: RPCOptions<R> | undefined) => Promise<void>;
export type RPCRequestAllOptions<R> = RPCRequestResponseOptions<R> & EncryptionOptions & {
mode?: Constructor<DeliveryMode>;
} & PriorityOptions;
export declare const queryAll: <Q, R>(rpc: RPC<Q, R>, groups: string[][], request: Q, responseHandler: (response: RPCResponse<R>[]) => Promise<void> | void, options?: RPCRequestAllOptions<R> | undefined) => Promise<void>;

@@ -10,2 +10,3 @@ import { SilentDelivery } from "@peerbit/stream-interface";

groups = [...groups].filter((x) => !x.find((y) => y === rpc.node.identity.publicKey.hashcode()));
const sendModeType = options?.mode || SilentDelivery;
let rng = Math.round(Math.random() * groups.length);

@@ -28,3 +29,3 @@ const startRng = rng;

...options,
mode: new SilentDelivery({ to: peersToQuery, redundancy: 1 }) // TODO configuration redundancy?
mode: new sendModeType({ to: peersToQuery, redundancy: 1 }) // TODO configuration redundancy?
});

@@ -31,0 +32,0 @@ for (const result of results) {

{
"name": "@peerbit/rpc",
"version": "3.0.25",
"version": "4.0.0",
"description": "RPC calls for peers",

@@ -37,9 +37,9 @@ "type": "module",

"@peerbit/logger": "1.0.2",
"@peerbit/program": "3.0.20",
"@peerbit/program": "4.0.0",
"@peerbit/time": "2.0.6"
},
"devDependencies": {
"@peerbit/test-utils": "^2.0.25"
"@peerbit/test-utils": "^2.0.26"
},
"gitHead": "a4da18ebc1b18e79693f96a79f2d7a83a35b0d29"
"gitHead": "9536898b1f74d42c4f97183b864945fa29422d3e"
}

@@ -18,4 +18,9 @@ import {

import { RequestV0, ResponseV0, RPCMessage } from "./encoding.js";
import { RPCOptions, logger, RPCResponse, PublishOptions } from "./io.js";
import {
logger,
RPCResponse,
EncryptionOptions,
RPCRequestOptions
} from "./io.js";
import {
DataEvent,

@@ -27,3 +32,6 @@ PublishOptions as PubSubPublishOptions

DataMessage,
DeliveryMode,
PriorityOptions,
SilentDelivery,
WithMode,
deliveryModeHasReceiver

@@ -186,2 +194,3 @@ } from "@peerbit/stream-interface";

topics: [this.topic],
priority: message.header.priority, // send back with same priority. TODO, make this better in the future

@@ -230,3 +239,3 @@ /// TODO make redundancy parameter configurable?

respondTo?: X25519PublicKey,
options?: PublishOptions
options?: EncryptionOptions
) {

@@ -261,4 +270,7 @@ const requestData = this._requestTypeIsUint8Array

private getPublishOptions(options?: PublishOptions): PubSubPublishOptions {
private getPublishOptions(
options?: EncryptionOptions & WithMode & PriorityOptions
): PubSubPublishOptions {
return {
priority: options?.priority,
mode: options?.mode,

@@ -274,3 +286,6 @@ topics: [this.topic]

*/
public async send(message: Q, options?: PublishOptions): Promise<void> {
public async send(
message: Q,
options?: EncryptionOptions & WithMode & PriorityOptions
): Promise<void> {
await this.node.services.pubsub.publish(

@@ -288,3 +303,3 @@ serialize(await this.seal(message, undefined, options)),

expectedResponders?: Set<string>,
options?: RPCOptions<R>
options?: RPCRequestOptions<R>
) {

@@ -350,3 +365,3 @@ return async (properties: {

request: Q,
options?: RPCOptions<R>
options?: RPCRequestOptions<R>
): Promise<RPCResponse<R>[]> {

@@ -353,0 +368,0 @@ // We are generatinga new encryption keypair for each send, so we now that when we get the responses, they are encrypted specifcally for me, and for this request

@@ -8,6 +8,6 @@ import {

import { logger as loggerFn } from "@peerbit/logger";
import { DeliveryMode } from "@peerbit/stream-interface";
import { PriorityOptions, WithMode } from "@peerbit/stream-interface";
export const logger = loggerFn({ module: "rpc" });
export type RPCOptions<R> = {
export type RPCRequestResponseOptions<R> = {
amount?: number;

@@ -18,5 +18,10 @@ timeout?: number;

signal?: AbortSignal;
} & PublishOptions;
};
export type PublishOptions = {
export type RPCRequestOptions<R> = RPCRequestResponseOptions<R> &
EncryptionOptions &
WithMode &
PriorityOptions;
export type EncryptionOptions = {
encryption?: {

@@ -26,6 +31,4 @@ key: X25519Keypair;

};
strict?: boolean;
mode?: DeliveryMode;
};
export type RPCResponse<R> = { response: R; from?: PublicSignKey };

@@ -1,4 +0,13 @@

import { SilentDelivery } from "@peerbit/stream-interface";
import {
DeliveryMode,
PriorityOptions,
SilentDelivery
} from "@peerbit/stream-interface";
import { RPC } from "./controller";
import { RPCOptions, RPCResponse } from "./io";
import {
EncryptionOptions,
RPCRequestResponseOptions,
RPCResponse
} from "./io";
import { Constructor } from "@dao-xyz/borsh";
export class MissingResponsesError extends Error {

@@ -9,2 +18,5 @@ constructor(message: string) {

}
export type RPCRequestAllOptions<R> = RPCRequestResponseOptions<R> &
EncryptionOptions & { mode?: Constructor<DeliveryMode> } & PriorityOptions;
export const queryAll = <Q, R>(

@@ -15,3 +27,3 @@ rpc: RPC<Q, R>,

responseHandler: (response: RPCResponse<R>[]) => Promise<void> | void,
options?: RPCOptions<R> | undefined
options?: RPCRequestAllOptions<R> | undefined
) => {

@@ -23,2 +35,3 @@ // In each shard/group only query a subset

const sendModeType = options?.mode || SilentDelivery;
let rng = Math.round(Math.random() * groups.length);

@@ -41,3 +54,3 @@ const startRng = rng;

...options,
mode: new SilentDelivery({ to: peersToQuery, redundancy: 1 }) // TODO configuration redundancy?
mode: new sendModeType({ to: peersToQuery, redundancy: 1 }) // TODO configuration redundancy?
});

@@ -44,0 +57,0 @@

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