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

@nimiq/rpc

Package Overview
Dependencies
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nimiq/rpc - npm Package Compare versions

Comparing version 0.1.0-beta.2 to 0.1.0-beta.3

25

dist/rpc.common.js

@@ -482,2 +482,25 @@ 'use strict';

}
class ReceiveOnlyPostMessageRpcClient extends PostMessageRpcClient {
constructor(targetWindow, allowedOrigin, requestId) {
super(targetWindow, allowedOrigin);
this._requestId = requestId;
}
async listenFor(command) {
if (!this._connected)
throw new Error('Client is not connected, call init first');
return new Promise((resolve, reject) => {
// Store the request resolvers
this._responseHandlers.set(this._requestId, { resolve, reject });
this._waitingRequests.add(this._requestId, command);
// Periodically check if recepient window is still open
const checkIfServerWasClosed = () => {
if (this._target.closed) {
reject(new Error('Window was closed'));
}
setTimeout(checkIfServerWasClosed, 500);
};
setTimeout(checkIfServerWasClosed, 500);
});
}
}
class RedirectRpcClient extends RpcClient {

@@ -699,2 +722,3 @@ constructor(targetURL, allowedOrigin) {

exports.PostMessageRpcClient = PostMessageRpcClient;
exports.ReceiveOnlyPostMessageRpcClient = ReceiveOnlyPostMessageRpcClient;
exports.RedirectRpcClient = RedirectRpcClient;

@@ -704,1 +728,2 @@ exports.RpcServer = RpcServer;

exports.UrlRpcEncoder = UrlRpcEncoder;
exports.RandomUtils = RandomUtils;

25

dist/rpc.es.js

@@ -479,2 +479,25 @@ class RandomUtils {

}
class ReceiveOnlyPostMessageRpcClient extends PostMessageRpcClient {
constructor(targetWindow, allowedOrigin, requestId) {
super(targetWindow, allowedOrigin);
this._requestId = requestId;
}
async listenFor(command) {
if (!this._connected)
throw new Error('Client is not connected, call init first');
return new Promise((resolve, reject) => {
// Store the request resolvers
this._responseHandlers.set(this._requestId, { resolve, reject });
this._waitingRequests.add(this._requestId, command);
// Periodically check if recepient window is still open
const checkIfServerWasClosed = () => {
if (this._target.closed) {
reject(new Error('Window was closed'));
}
setTimeout(checkIfServerWasClosed, 500);
};
setTimeout(checkIfServerWasClosed, 500);
});
}
}
class RedirectRpcClient extends RpcClient {

@@ -694,2 +717,2 @@ constructor(targetURL, allowedOrigin) {

export { RpcClient, PostMessageRpcClient, RedirectRpcClient, RpcServer, State, ResponseStatus, UrlRpcEncoder };
export { RpcClient, PostMessageRpcClient, ReceiveOnlyPostMessageRpcClient, RedirectRpcClient, RpcServer, State, ResponseStatus, UrlRpcEncoder, RandomUtils };

@@ -484,2 +484,25 @@ (function (global, factory) {

}
class ReceiveOnlyPostMessageRpcClient extends PostMessageRpcClient {
constructor(targetWindow, allowedOrigin, requestId) {
super(targetWindow, allowedOrigin);
this._requestId = requestId;
}
async listenFor(command) {
if (!this._connected)
throw new Error('Client is not connected, call init first');
return new Promise((resolve, reject) => {
// Store the request resolvers
this._responseHandlers.set(this._requestId, { resolve, reject });
this._waitingRequests.add(this._requestId, command);
// Periodically check if recepient window is still open
const checkIfServerWasClosed = () => {
if (this._target.closed) {
reject(new Error('Window was closed'));
}
setTimeout(checkIfServerWasClosed, 500);
};
setTimeout(checkIfServerWasClosed, 500);
});
}
}
class RedirectRpcClient extends RpcClient {

@@ -701,2 +724,3 @@ constructor(targetURL, allowedOrigin) {

exports.PostMessageRpcClient = PostMessageRpcClient;
exports.ReceiveOnlyPostMessageRpcClient = ReceiveOnlyPostMessageRpcClient;
exports.RedirectRpcClient = RedirectRpcClient;

@@ -706,2 +730,3 @@ exports.RpcServer = RpcServer;

exports.UrlRpcEncoder = UrlRpcEncoder;
exports.RandomUtils = RandomUtils;

@@ -708,0 +733,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

export * from './RpcClient';
export * from './RpcServer';
export * from './UrlRpcEncoder';
export * from './RandomUtils';

9

dist/src/RpcClient.d.ts

@@ -19,5 +19,5 @@ import { ResponseMessage } from './Messages';

export declare class PostMessageRpcClient extends RpcClient {
private readonly _target;
protected readonly _target: Window;
protected _connected: boolean;
private readonly _receiveListener;
private _connected;
constructor(targetWindow: Window, allowedOrigin: string);

@@ -29,2 +29,7 @@ init(): Promise<void>;

}
export declare class ReceiveOnlyPostMessageRpcClient extends PostMessageRpcClient {
private _requestId;
constructor(targetWindow: Window, allowedOrigin: string, requestId: number);
listenFor(command: string): Promise<any>;
}
export declare class RedirectRpcClient extends RpcClient {

@@ -31,0 +36,0 @@ private readonly _target;

{
"name": "@nimiq/rpc",
"version": "0.1.0-beta.2",
"version": "0.1.0-beta.3",
"description": "RPC Client/Server",

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

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