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

@nimiq/rpc

Package Overview
Dependencies
Maintainers
8
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.2.1-beta.1 to 0.2.1-beta.2

69

dist/rpc.common.js

@@ -454,3 +454,2 @@ 'use strict';

id: RandomUtils.generateRandomId(),
persistInUrl: true,
});

@@ -479,3 +478,3 @@ }

}
super._receive(message);
super._receive(message, false);
}

@@ -562,18 +561,18 @@ async _call(request) {

async init() {
let message = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (message) {
window.sessionStorage.setItem(`response-${message.data.id}`, JSONUtils.stringify(message));
// Check for a response in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`response-${searchParams.get('id')}`));
// Check for a stored response referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const response = window.sessionStorage.getItem(`response-${searchParams.get('id')}`);
if (response) {
this._receive(JSONUtils.parse(response), false);
return;
}
}
if (message) {
this._receive(message, false);
}
else {
this._rejectOnBack();
}
this._rejectOnBack();
}

@@ -704,4 +703,9 @@ /* tslint:disable-next-line:no-empty */

}
toRequestUrl(baseUrl) {
return UrlRpcEncoder.prepareRedirectInvocation(baseUrl, this.id, this.returnURL || POSTMESSAGE_RETURN_URL, this.data.command, this.data.args);
toRequestObject() {
return {
origin: this._origin,
data: this._data,
returnURL: this._returnURL || POSTMESSAGE_RETURN_URL,
source: typeof this._source === 'string' ? this._source : null,
};
}

@@ -743,18 +747,20 @@ }

return;
let message = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (message) {
window.sessionStorage.setItem(`request-${message.data.id}`, JSONUtils.stringify(message));
// Check for a request in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`request-${searchParams.get('id')}`));
// Check for a stored request referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const request = window.sessionStorage.getItem(`request-${searchParams.get('id')}`);
if (request) {
this._receive(JSONUtils.parse(request), false);
return;
}
}
if (message) {
window.clearTimeout(this._clientTimeout);
this._receive(message, false);
}
}
_receive(message, persistMessage = true) {
window.clearTimeout(this._clientTimeout);
let state = null;

@@ -785,8 +791,3 @@ try {

if (persistMessage) {
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify({
data: state.data,
origin: state.origin,
returnURL: POSTMESSAGE_RETURN_URL,
source: null,
}));
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify(state.toRequestObject()));
}

@@ -793,0 +794,0 @@ const url = new URL(window.location.href);

@@ -451,3 +451,2 @@ /* tslint:disable:no-bitwise */

id: RandomUtils.generateRandomId(),
persistInUrl: true,
});

@@ -476,3 +475,3 @@ }

}
super._receive(message);
super._receive(message, false);
}

@@ -559,18 +558,18 @@ async _call(request) {

async init() {
let message = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (message) {
window.sessionStorage.setItem(`response-${message.data.id}`, JSONUtils.stringify(message));
// Check for a response in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`response-${searchParams.get('id')}`));
// Check for a stored response referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const response = window.sessionStorage.getItem(`response-${searchParams.get('id')}`);
if (response) {
this._receive(JSONUtils.parse(response), false);
return;
}
}
if (message) {
this._receive(message, false);
}
else {
this._rejectOnBack();
}
this._rejectOnBack();
}

@@ -701,4 +700,9 @@ /* tslint:disable-next-line:no-empty */

}
toRequestUrl(baseUrl) {
return UrlRpcEncoder.prepareRedirectInvocation(baseUrl, this.id, this.returnURL || POSTMESSAGE_RETURN_URL, this.data.command, this.data.args);
toRequestObject() {
return {
origin: this._origin,
data: this._data,
returnURL: this._returnURL || POSTMESSAGE_RETURN_URL,
source: typeof this._source === 'string' ? this._source : null,
};
}

@@ -740,18 +744,20 @@ }

return;
let message = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (message) {
window.sessionStorage.setItem(`request-${message.data.id}`, JSONUtils.stringify(message));
// Check for a request in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`request-${searchParams.get('id')}`));
// Check for a stored request referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const request = window.sessionStorage.getItem(`request-${searchParams.get('id')}`);
if (request) {
this._receive(JSONUtils.parse(request), false);
return;
}
}
if (message) {
window.clearTimeout(this._clientTimeout);
this._receive(message, false);
}
}
_receive(message, persistMessage = true) {
window.clearTimeout(this._clientTimeout);
let state = null;

@@ -782,8 +788,3 @@ try {

if (persistMessage) {
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify({
data: state.data,
origin: state.origin,
returnURL: POSTMESSAGE_RETURN_URL,
source: null,
}));
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify(state.toRequestObject()));
}

@@ -790,0 +791,0 @@ const url = new URL(window.location.href);

@@ -456,3 +456,2 @@ (function (global, factory) {

id: RandomUtils.generateRandomId(),
persistInUrl: true,
});

@@ -481,3 +480,3 @@ }

}
super._receive(message);
super._receive(message, false);
}

@@ -564,18 +563,18 @@ async _call(request) {

async init() {
let message = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (message) {
window.sessionStorage.setItem(`response-${message.data.id}`, JSONUtils.stringify(message));
// Check for a response in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectResponse(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`response-${searchParams.get('id')}`));
// Check for a stored response referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const response = window.sessionStorage.getItem(`response-${searchParams.get('id')}`);
if (response) {
this._receive(JSONUtils.parse(response), false);
return;
}
}
if (message) {
this._receive(message, false);
}
else {
this._rejectOnBack();
}
this._rejectOnBack();
}

@@ -706,4 +705,9 @@ /* tslint:disable-next-line:no-empty */

}
toRequestUrl(baseUrl) {
return UrlRpcEncoder.prepareRedirectInvocation(baseUrl, this.id, this.returnURL || POSTMESSAGE_RETURN_URL, this.data.command, this.data.args);
toRequestObject() {
return {
origin: this._origin,
data: this._data,
returnURL: this._returnURL || POSTMESSAGE_RETURN_URL,
source: typeof this._source === 'string' ? this._source : null,
};
}

@@ -745,18 +749,20 @@ }

return;
let message = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (message) {
window.sessionStorage.setItem(`request-${message.data.id}`, JSONUtils.stringify(message));
// Check for a request in the URL (also removes params)
const urlMessage = UrlRpcEncoder.receiveRedirectCommand(window.location);
if (urlMessage) {
this._receive(urlMessage);
return;
}
else {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
message = JSONUtils.parse(window.sessionStorage.getItem(`request-${searchParams.get('id')}`));
// Check for a stored request referenced by a URL 'id' parameter
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('id')) {
const request = window.sessionStorage.getItem(`request-${searchParams.get('id')}`);
if (request) {
this._receive(JSONUtils.parse(request), false);
return;
}
}
if (message) {
window.clearTimeout(this._clientTimeout);
this._receive(message, false);
}
}
_receive(message, persistMessage = true) {
window.clearTimeout(this._clientTimeout);
let state = null;

@@ -787,8 +793,3 @@ try {

if (persistMessage) {
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify({
data: state.data,
origin: state.origin,
returnURL: POSTMESSAGE_RETURN_URL,
source: null,
}));
sessionStorage.setItem(`request-${state.data.id}`, JSONUtils.stringify(state.toRequestObject()));
}

@@ -795,0 +796,0 @@ const url = new URL(window.location.href);

@@ -10,3 +10,2 @@ import { PostMessage, RedirectRequest, ResponseStatus } from './Messages';

id: number;
persistInUrl?: boolean | undefined;
};

@@ -25,3 +24,3 @@ readonly returnURL: string | null;

reply(status: ResponseStatus, result: any): void;
toRequestUrl(baseUrl: string): string;
toRequestObject(): RedirectRequest;
}
{
"name": "@nimiq/rpc",
"version": "0.2.1-beta.1",
"version": "0.2.1-beta.2",
"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