Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interval/sdk

Package Overview
Dependencies
Maintainers
3
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interval/sdk - npm Package Compare versions

Comparing version 0.35.1 to 0.35.2

5

dist/classes/DataChannelConnection.d.ts
import { PeerConnection, IceServer } from 'node-datachannel';
import type { DuplexRPCClient } from './DuplexRPCClient';
import { HostSchema, PeerConnectionInitializer, ClientSchema } from '../internalRpcSchema';
import ISocket, { DataChannelSocket } from './ISocket';
import ISocket, { DataChannelSocket, ISocketConfig } from './ISocket';
export default class DataChannelConnection {

@@ -9,3 +9,3 @@ peer: PeerConnection;

rpc?: DuplexRPCClient<ClientSchema, HostSchema>;
constructor({ id, iceServers, send, rpcConstructor, }: {
constructor({ id, iceServers, send, rpcConstructor, isocketConfig, }: {
id: string;

@@ -18,3 +18,4 @@ iceServers: (string | IceServer)[];

}) => DuplexRPCClient<ClientSchema, HostSchema>;
isocketConfig?: ISocketConfig;
});
}

4

dist/classes/DataChannelConnection.js

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

class DataChannelConnection {
constructor({ id, iceServers, send, rpcConstructor, }) {
constructor({ id, iceServers, send, rpcConstructor, isocketConfig, }) {
this.peer = new node_datachannel_1.PeerConnection(id, {

@@ -51,3 +51,3 @@ iceServers,

this.ds = ds;
const communicator = new ISocket_1.default(ds);
const communicator = new ISocket_1.default(ds, { id, ...isocketConfig });
this.rpc = rpcConstructor({

@@ -54,0 +54,0 @@ communicator,

@@ -18,2 +18,3 @@ import { z } from 'zod';

handlers: DuplexRPCHandlers<ResponderSchema>;
retryChunkIntervalMs?: number;
}

@@ -31,2 +32,3 @@ /**

export declare class DuplexRPCClient<CallerSchema extends MethodDef, ResponderSchema extends MethodDef> {
#private;
communicator: ISocket;

@@ -40,3 +42,3 @@ canCall: CallerSchema;

messageChunks: Map<string, string[]>;
constructor({ communicator, canCall, canRespondTo, handlers, }: CreateDuplexRPCClientProps<CallerSchema, ResponderSchema>);
constructor({ communicator, canCall, canRespondTo, handlers, retryChunkIntervalMs, }: CreateDuplexRPCClientProps<CallerSchema, ResponderSchema>);
private packageResponse;

@@ -43,0 +45,0 @@ private packageCall;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _DuplexRPCClient_retryChunkIntervalMs;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,3 +21,5 @@ exports.DuplexRPCClient = void 0;

const internalRpcSchema_1 = require("../internalRpcSchema");
const IntervalClient_1 = require("./IntervalClient");
const IntervalError_1 = __importDefault(require("./IntervalError"));
const ISocket_1 = require("./ISocket");
let count = 0;

@@ -38,5 +52,6 @@ function generateId() {

class DuplexRPCClient {
constructor({ communicator, canCall, canRespondTo, handlers, }) {
constructor({ communicator, canCall, canRespondTo, handlers, retryChunkIntervalMs, }) {
this.pendingCalls = new Map();
this.messageChunks = new Map();
_DuplexRPCClient_retryChunkIntervalMs.set(this, 100);
this.communicator = communicator;

@@ -47,2 +62,5 @@ this.communicator.onMessage.attach(this.onmessage.bind(this));

this.handlers = handlers;
if (retryChunkIntervalMs && retryChunkIntervalMs > 0) {
__classPrivateFieldSet(this, _DuplexRPCClient_retryChunkIntervalMs, retryChunkIntervalMs, "f");
}
}

@@ -209,6 +227,31 @@ packageResponse({ id, methodName, data, }) {

if (Array.isArray(msg)) {
Promise.all(msg.map(chunk => {
this.communicator.send(chunk);
})).catch(err => {
reject(err);
Promise.allSettled(msg.map(async (chunk) => {
const NUM_TRIES_PER_CHUNK = 3;
// If a chunk times out, retry it a few times
for (let i = 0; i <= NUM_TRIES_PER_CHUNK; i++) {
try {
return await this.communicator.send(chunk);
}
catch (err) {
if (err instanceof ISocket_1.TimeoutError) {
// console.debug(
// `Chunk timed out, retrying in ${
// this.#retryChunkIntervalMs
// }ms...`
// )
await (0, IntervalClient_1.sleep)(__classPrivateFieldGet(this, _DuplexRPCClient_retryChunkIntervalMs, "f"));
}
else {
throw err;
}
}
}
throw new ISocket_1.TimeoutError();
})).then(responses => {
// reject the first failed promise, if any
for (const response of responses) {
if (response.status === 'rejected') {
reject(response.reason);
}
}
});

@@ -225,1 +268,2 @@ }

exports.DuplexRPCClient = DuplexRPCClient;
_DuplexRPCClient_retryChunkIntervalMs = new WeakMap();

@@ -8,3 +8,3 @@ import type { WebSocket as NodeWebSocket } from 'ws';

}
interface ISocketConfig {
export interface ISocketConfig {
connectTimeout?: number;

@@ -93,2 +93,1 @@ sendTimeout?: number;

}
export {};

@@ -23,3 +23,7 @@ import Routes from './classes/Routes';

retryIntervalMs?: number;
retryChunkIntervalMs?: number;
pingIntervalMs?: number;
connectTimeoutMs?: number;
sendTimeoutMs?: number;
pingTimeoutMs?: number;
closeUnresponsiveConnectionTimeoutMs?: number;

@@ -26,0 +30,0 @@ reinitializeBatchTimeoutMs?: number;

{
"name": "@interval/sdk",
"version": "0.35.1",
"version": "0.35.2",
"homepage": "https://interval.com",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is too big to display

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