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

smoldot

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smoldot - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

1

dist/cjs/internals/client.d.ts

@@ -11,3 +11,2 @@ import { Client, ClientOptions, SmoldotBytecode } from '../public-types.js';

* @see Connection
* @throws {@link ConnectionError} If the multiaddress couldn't be parsed or contains an invalid protocol.
*/

@@ -14,0 +13,0 @@ connect(config: ConnectionConfig): Connection;

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

chainIds: new WeakMap(),
currentTaskName: null,
connections: new Map(),

@@ -80,3 +79,3 @@ addChainResults: [],

console.error("Smoldot has panicked" +
(state.currentTaskName ? (" while executing task `" + state.currentTaskName + "`") : "") +
(event.currentTask ? (" while executing task `" + event.currentTask + "`") : "") +
". This is a bug in smoldot. Please open an issue at " +

@@ -102,3 +101,2 @@ "https://github.com/smol-dot/smoldot/issues with the following message:\n" +

state.chains.clear();
state.currentTaskName = null;
const cb = state.onExecutorShutdownOrWasmPanic;

@@ -131,6 +129,2 @@ state.onExecutorShutdownOrWasmPanic = () => { };

}
case "current-task": {
state.currentTaskName = event.taskName;
break;
}
case "new-connection": {

@@ -392,3 +386,2 @@ const connectionId = event.connectionId;

state.chains.clear();
state.currentTaskName = null;
// Wait for the `executor-shutdown` event to be generated.

@@ -395,0 +388,0 @@ yield new Promise((resolve) => state.onExecutorShutdownOrWasmPanic = resolve);

4

dist/cjs/internals/local-instance.d.ts

@@ -49,7 +49,5 @@ /**

} | {
ty: "current-task";
taskName: string | null;
} | {
ty: "wasm-panic";
message: string;
currentTask: string | null;
} | {

@@ -56,0 +54,0 @@ ty: "executor-shutdown";

@@ -43,2 +43,3 @@ "use strict";

instance: null,
currentTask: null,
bufferIndices: new Array(),

@@ -59,3 +60,3 @@ advanceExecutionPromise: null,

const message = buffer.utf8BytesToString(new Uint8Array(instance.exports.memory.buffer), ptr, len);
eventCallback({ ty: "wasm-panic", message });
eventCallback({ ty: "wasm-panic", message, currentTask: state.currentTask });
state.onShutdownExecutorOrWasmPanic();

@@ -149,3 +150,2 @@ state.onShutdownExecutorOrWasmPanic = () => { };

buffer.writeUInt32LE(mem, errorBufferIndexPtr, 0);
buffer.writeUInt8(mem, errorBufferIndexPtr + 4, 1); // TODO: remove isBadAddress param since it's always true
return 1;

@@ -184,6 +184,6 @@ }

const taskName = buffer.utf8BytesToString(new Uint8Array(state.instance.exports.memory.buffer), ptr, len);
eventCallback({ ty: "current-task", taskName });
state.currentTask = taskName;
},
current_task_exit: () => {
eventCallback({ ty: "current-task", taskName: null });
state.currentTask = null;
}

@@ -296,3 +296,7 @@ };

state.instance = null;
eventCallback({ ty: "wasm-panic", message: `proc_exit called: ${retCode}` });
eventCallback({
ty: "wasm-panic",
message: `proc_exit called: ${retCode}`,
currentTask: state.currentTask
});
state.onShutdownExecutorOrWasmPanic();

@@ -299,0 +303,0 @@ state.onShutdownExecutorOrWasmPanic = () => { };

@@ -67,6 +67,19 @@ "use strict";

if (config.address.ty === "websocket") {
const connection = new WebSocket(config.address.url);
connection.binaryType = 'arraybuffer';
// Even though the WHATWG specification (<https://websockets.spec.whatwg.org/#dom-websocket-websocket>)
// doesn't mention it, `new WebSocket` can throw an exception if the URL is forbidden
// for security reasons. We absord this exception as soon as it is thrown.
// `connection` can be either a `WebSocket` object (the normal case), or a string
// indicating an error message that must be propagated with `onConnectionReset` as soon
// as possible, or `null` if the API user considers the connection as reset.
let connection;
try {
connection = new WebSocket(config.address.url);
}
catch (error) {
connection = error instanceof Error ? error.toString() : "Exception thrown by new WebSocket";
}
const bufferedAmountCheck = { quenedUnreportedBytes: 0, nextTimeout: 10 };
const checkBufferedAmount = () => {
if (!(connection instanceof WebSocket))
return;
if (connection.readyState != 1)

@@ -93,22 +106,45 @@ return;

};
connection.onopen = () => {
config.onOpen({
type: 'single-stream', handshake: 'multistream-select-noise-yamux',
initialWritableBytes: 1024 * 1024, writeClosable: false,
});
};
connection.onclose = (event) => {
const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
config.onConnectionReset(message);
};
connection.onmessage = (msg) => {
config.onMessage(new Uint8Array(msg.data));
};
if (connection instanceof WebSocket) {
connection.binaryType = 'arraybuffer';
connection.onopen = () => {
config.onOpen({
type: 'single-stream', handshake: 'multistream-select-noise-yamux',
initialWritableBytes: 1024 * 1024, writeClosable: false,
});
};
connection.onclose = (event) => {
const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
config.onConnectionReset(message);
};
connection.onmessage = (msg) => {
config.onMessage(new Uint8Array(msg.data));
};
}
else {
setTimeout(() => {
if (connection && !(connection instanceof WebSocket)) {
config.onConnectionReset(connection);
connection = null;
}
}, 1);
}
return {
reset: () => {
connection.onopen = null;
connection.onclose = null;
connection.onmessage = null;
connection.onerror = null;
connection.close();
if (connection instanceof WebSocket) {
connection.onopen = null;
connection.onclose = null;
connection.onmessage = null;
connection.onerror = null;
// According to the WebSocket specification, calling `close()` when a WebSocket
// isn't fully opened yet is completely legal and seemingly a normal thing to
// do (see <https://websockets.spec.whatwg.org/#dom-websocket-close>).
// Unfortunately, browsers print a warning in the console if you do that. To
// avoid these warnings, we only call `close()` if the connection is fully
// opened. According to <https://websockets.spec.whatwg.org/#garbage-collection>,
// removing all the event listeners will cause the WebSocket to be garbage
// collected, which should have the same effect as `close()`.
if (connection.readyState == WebSocket.OPEN)
connection.close();
}
connection = null;
},

@@ -115,0 +151,0 @@ send: (data) => {

@@ -11,3 +11,2 @@ import { Client, ClientOptions, SmoldotBytecode } from '../public-types.js';

* @see Connection
* @throws {@link ConnectionError} If the multiaddress couldn't be parsed or contains an invalid protocol.
*/

@@ -14,0 +13,0 @@ connect(config: ConnectionConfig): Connection;

@@ -65,3 +65,2 @@ // Smoldot

chainIds: new WeakMap(),
currentTaskName: null,
connections: new Map(),

@@ -77,3 +76,3 @@ addChainResults: [],

console.error("Smoldot has panicked" +
(state.currentTaskName ? (" while executing task `" + state.currentTaskName + "`") : "") +
(event.currentTask ? (" while executing task `" + event.currentTask + "`") : "") +
". This is a bug in smoldot. Please open an issue at " +

@@ -99,3 +98,2 @@ "https://github.com/smol-dot/smoldot/issues with the following message:\n" +

state.chains.clear();
state.currentTaskName = null;
const cb = state.onExecutorShutdownOrWasmPanic;

@@ -128,6 +126,2 @@ state.onExecutorShutdownOrWasmPanic = () => { };

}
case "current-task": {
state.currentTaskName = event.taskName;
break;
}
case "new-connection": {

@@ -389,3 +383,2 @@ const connectionId = event.connectionId;

state.chains.clear();
state.currentTaskName = null;
// Wait for the `executor-shutdown` event to be generated.

@@ -392,0 +385,0 @@ yield new Promise((resolve) => state.onExecutorShutdownOrWasmPanic = resolve);

@@ -49,7 +49,5 @@ /**

} | {
ty: "current-task";
taskName: string | null;
} | {
ty: "wasm-panic";
message: string;
currentTask: string | null;
} | {

@@ -56,0 +54,0 @@ ty: "executor-shutdown";

@@ -40,2 +40,3 @@ // Smoldot

instance: null,
currentTask: null,
bufferIndices: new Array(),

@@ -56,3 +57,3 @@ advanceExecutionPromise: null,

const message = buffer.utf8BytesToString(new Uint8Array(instance.exports.memory.buffer), ptr, len);
eventCallback({ ty: "wasm-panic", message });
eventCallback({ ty: "wasm-panic", message, currentTask: state.currentTask });
state.onShutdownExecutorOrWasmPanic();

@@ -146,3 +147,2 @@ state.onShutdownExecutorOrWasmPanic = () => { };

buffer.writeUInt32LE(mem, errorBufferIndexPtr, 0);
buffer.writeUInt8(mem, errorBufferIndexPtr + 4, 1); // TODO: remove isBadAddress param since it's always true
return 1;

@@ -181,6 +181,6 @@ }

const taskName = buffer.utf8BytesToString(new Uint8Array(state.instance.exports.memory.buffer), ptr, len);
eventCallback({ ty: "current-task", taskName });
state.currentTask = taskName;
},
current_task_exit: () => {
eventCallback({ ty: "current-task", taskName: null });
state.currentTask = null;
}

@@ -293,3 +293,7 @@ };

state.instance = null;
eventCallback({ ty: "wasm-panic", message: `proc_exit called: ${retCode}` });
eventCallback({
ty: "wasm-panic",
message: `proc_exit called: ${retCode}`,
currentTask: state.currentTask
});
state.onShutdownExecutorOrWasmPanic();

@@ -296,0 +300,0 @@ state.onShutdownExecutorOrWasmPanic = () => { };

@@ -57,6 +57,19 @@ // Smoldot

if (config.address.ty === "websocket") {
const connection = new WebSocket(config.address.url);
connection.binaryType = 'arraybuffer';
// Even though the WHATWG specification (<https://websockets.spec.whatwg.org/#dom-websocket-websocket>)
// doesn't mention it, `new WebSocket` can throw an exception if the URL is forbidden
// for security reasons. We absord this exception as soon as it is thrown.
// `connection` can be either a `WebSocket` object (the normal case), or a string
// indicating an error message that must be propagated with `onConnectionReset` as soon
// as possible, or `null` if the API user considers the connection as reset.
let connection;
try {
connection = new WebSocket(config.address.url);
}
catch (error) {
connection = error instanceof Error ? error.toString() : "Exception thrown by new WebSocket";
}
const bufferedAmountCheck = { quenedUnreportedBytes: 0, nextTimeout: 10 };
const checkBufferedAmount = () => {
if (!(connection instanceof WebSocket))
return;
if (connection.readyState != 1)

@@ -83,22 +96,45 @@ return;

};
connection.onopen = () => {
config.onOpen({
type: 'single-stream', handshake: 'multistream-select-noise-yamux',
initialWritableBytes: 1024 * 1024, writeClosable: false,
});
};
connection.onclose = (event) => {
const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
config.onConnectionReset(message);
};
connection.onmessage = (msg) => {
config.onMessage(new Uint8Array(msg.data));
};
if (connection instanceof WebSocket) {
connection.binaryType = 'arraybuffer';
connection.onopen = () => {
config.onOpen({
type: 'single-stream', handshake: 'multistream-select-noise-yamux',
initialWritableBytes: 1024 * 1024, writeClosable: false,
});
};
connection.onclose = (event) => {
const message = "Error code " + event.code + (!!event.reason ? (": " + event.reason) : "");
config.onConnectionReset(message);
};
connection.onmessage = (msg) => {
config.onMessage(new Uint8Array(msg.data));
};
}
else {
setTimeout(() => {
if (connection && !(connection instanceof WebSocket)) {
config.onConnectionReset(connection);
connection = null;
}
}, 1);
}
return {
reset: () => {
connection.onopen = null;
connection.onclose = null;
connection.onmessage = null;
connection.onerror = null;
connection.close();
if (connection instanceof WebSocket) {
connection.onopen = null;
connection.onclose = null;
connection.onmessage = null;
connection.onerror = null;
// According to the WebSocket specification, calling `close()` when a WebSocket
// isn't fully opened yet is completely legal and seemingly a normal thing to
// do (see <https://websockets.spec.whatwg.org/#dom-websocket-close>).
// Unfortunately, browsers print a warning in the console if you do that. To
// avoid these warnings, we only call `close()` if the connection is fully
// opened. According to <https://websockets.spec.whatwg.org/#garbage-collection>,
// removing all the event listeners will cause the WebSocket to be garbage
// collected, which should have the same effect as `close()`.
if (connection.readyState == WebSocket.OPEN)
connection.close();
}
connection = null;
},

@@ -105,0 +141,0 @@ send: (data) => {

{
"name": "smoldot",
"version": "1.0.10",
"version": "1.0.11",
"description": "Light client that connects to Polkadot and Substrate-based blockchains",
"author": "Parity Technologies <admin@parity.io>",
"contributors": [
"Parity Technologies <admin@parity.io>",
"Pierre Krieger <pierre.krieger1708@gmail.com>"
],
"license": "GPL-3.0-or-later WITH Classpath-exception-2.0",

@@ -7,0 +10,0 @@ "homepage": "https://github.com/smol-dot/smoldot",

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

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

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

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

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

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