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

@bytecodealliance/preview2-shim

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bytecodealliance/preview2-shim - npm Package Compare versions

Comparing version 0.16.0 to 0.16.1

21

lib/io/worker-http.js

@@ -0,6 +1,3 @@

import { createReadableStream, getStreamOrThrow } from "./worker-thread.js";
import {
createReadableStream,
getStreamOrThrow,
} from "./worker-thread.js";
import {
createServer,

@@ -120,3 +117,3 @@ request as httpRequest,

path: pathWithQuery,
timeout: connectTimeout && Number(connectTimeout),
timeout: connectTimeout && Number(connectTimeout / 1_000_000n),
});

@@ -131,3 +128,3 @@ break;

path: pathWithQuery,
timeout: connectTimeout && Number(connectTimeout),
timeout: connectTimeout && Number(connectTimeout / 1_000_000n),
});

@@ -148,2 +145,8 @@ break;

const res = await new Promise((resolve, reject) => {
req.once('timeout', () => {
reject({
tag: "connection-timeout"
});
req.destroy();
});
req.once("response", resolve);

@@ -153,6 +156,6 @@ req.once("close", () => reject);

});
if (firstByteTimeout) res.setTimeout(Number(firstByteTimeout));
if (firstByteTimeout) res.setTimeout(Number(firstByteTimeout / 1_000_000n));
if (betweenBytesTimeout)
res.once("readable", () => {
res.setTimeout(Number(betweenBytesTimeout));
res.setTimeout(Number(betweenBytesTimeout / 1_000_000n));
});

@@ -163,3 +166,3 @@ const bodyStreamId = createReadableStream(res);

headers: Array.from(Object.entries(res.headers)),
bodyStreamId
bodyStreamId,
};

@@ -166,0 +169,0 @@ } catch (e) {

@@ -41,3 +41,3 @@ import { createPoll } from "../io/worker-io.js";

monotonicClock.now[symbolCabiLower] = () => hrtime.bigint;
wallClock.resolution[symbolCabiLower] = (memory) => {
wallClock.resolution[symbolCabiLower] = ({ memory }) => {
let buf32 = new Int32Array(memory.buffer);

@@ -53,3 +53,3 @@ return function now(retptr) {

wallClock.now[symbolCabiLower] = (memory) => {
wallClock.now[symbolCabiLower] = ({ memory }) => {
let buf32 = new Int32Array(memory.buffer);

@@ -56,0 +56,0 @@ let buf64 = new BigInt64Array(memory.buffer);

@@ -178,15 +178,11 @@ import {

const defaultHttpTimeout = 600_000_000_000n;
class RequestOptions {
#connectTimeout;
#firstByteTimeout;
#betweenBytesTimeout;
//The WASI Duration is nanoseconds, js timers are set with Ms.
//We store the data as nanos, but provide TimeoutMs methods for
//convenience in setting timers elsewhere
#connectTimeout = defaultHttpTimeout;
#firstByteTimeout = defaultHttpTimeout;
#betweenBytesTimeout = defaultHttpTimeout;
connectTimeout() {
return this.#connectTimeout;
}
connectTimeoutMs() {
return this.#connectTimeout / 1_000_000;
}
setConnectTimeout(duration) {

@@ -198,5 +194,2 @@ this.#connectTimeout = duration;

}
firstByteTimeoutMs() {
return this.#firstByteTimeout / 1_000_000;
}
setFirstByteTimeout(duration) {

@@ -208,5 +201,2 @@ this.#firstByteTimeout = duration;

}
betweenBytesTimeoutMs() {
return this.#betweenBytesTimeout / 1_000_000;
}
setBetweenBytesTimeout(duration) {

@@ -290,5 +280,5 @@ this.#betweenBytesTimeout = duration;

static _handle(request, options) {
const connectTimeout = options?.connectTimeoutMs();
const betweenBytesTimeout = options?.betweenBytesTimeoutMs();
const firstByteTimeout = options?.firstByteTimeoutMs();
const connectTimeout = options?.connectTimeout();
const betweenBytesTimeout = options?.betweenBytesTimeout();
const firstByteTimeout = options?.firstByteTimeout();
const scheme = schemeString(request.#scheme);

@@ -310,3 +300,3 @@ // note: host header is automatically added by Node.js

betweenBytesTimeout,
firstByteTimeout
firstByteTimeout,
);

@@ -313,0 +303,0 @@ }

@@ -34,3 +34,3 @@ import { randomBytes, randomFillSync } from "node:crypto";

randomBytes[Symbol.for("cabiLower")] = ({ memory, realloc }) => {
getRandomBytes[Symbol.for("cabiLower")] = ({ memory, realloc }) => {
let buf32 = new Uint32Array(memory.buffer);

@@ -37,0 +37,0 @@ return function randomBytes(len, retptr) {

{
"name": "@bytecodealliance/preview2-shim",
"version": "0.16.0",
"version": "0.16.1",
"description": "WASI Preview2 shim for JS environments",

@@ -5,0 +5,0 @@ "author": "Guy Bedford, Eduardo Rodrigues<16357187+eduardomourar@users.noreply.github.com>",

export namespace WasiCliStderr {
export function getStderr(): OutputStream;
}
import type { OutputStream } from '../interfaces/wasi-io-streams.js';
import type { OutputStream } from './wasi-io-streams.js';
export { OutputStream };
export namespace WasiCliStdin {
export function getStdin(): InputStream;
}
import type { InputStream } from '../interfaces/wasi-io-streams.js';
import type { InputStream } from './wasi-io-streams.js';
export { InputStream };
export namespace WasiCliStdout {
export function getStdout(): OutputStream;
}
import type { OutputStream } from '../interfaces/wasi-io-streams.js';
import type { OutputStream } from './wasi-io-streams.js';
export { OutputStream };

@@ -8,3 +8,3 @@ export namespace WasiCliTerminalStderr {

}
import type { TerminalOutput } from '../interfaces/wasi-cli-terminal-output.js';
import type { TerminalOutput } from './wasi-cli-terminal-output.js';
export { TerminalOutput };

@@ -8,3 +8,3 @@ export namespace WasiCliTerminalStdin {

}
import type { TerminalInput } from '../interfaces/wasi-cli-terminal-input.js';
import type { TerminalInput } from './wasi-cli-terminal-input.js';
export { TerminalInput };

@@ -8,3 +8,3 @@ export namespace WasiCliTerminalStdout {

}
import type { TerminalOutput } from '../interfaces/wasi-cli-terminal-output.js';
import type { TerminalOutput } from './wasi-cli-terminal-output.js';
export { TerminalOutput };

@@ -26,3 +26,3 @@ export namespace WasiClocksMonotonicClock {

}
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };

@@ -29,0 +29,0 @@ /**

@@ -7,3 +7,3 @@ export namespace WasiFilesystemPreopens {

}
import type { Descriptor } from '../interfaces/wasi-filesystem-types.js';
import type { Descriptor } from './wasi-filesystem-types.js';
export { Descriptor };

@@ -263,9 +263,9 @@ export namespace WasiFilesystemTypes {

}
import type { InputStream } from '../interfaces/wasi-io-streams.js';
import type { InputStream } from './wasi-io-streams.js';
export { InputStream };
import type { OutputStream } from '../interfaces/wasi-io-streams.js';
import type { OutputStream } from './wasi-io-streams.js';
export { OutputStream };
import type { Error } from '../interfaces/wasi-io-streams.js';
import type { Error } from './wasi-io-streams.js';
export { Error };
import type { Datetime } from '../interfaces/wasi-clocks-wall-clock.js';
import type { Datetime } from './wasi-clocks-wall-clock.js';
export { Datetime };

@@ -643,2 +643,6 @@ /**

export class DirectoryEntryStream {
readDirectoryEntry(): DirectoryEntry | undefined;
}
export class Descriptor {

@@ -673,5 +677,1 @@ readViaStream(offset: Filesize): InputStream;

}
export class DirectoryEntryStream {
readDirectoryEntry(): DirectoryEntry | undefined;
}

@@ -16,5 +16,5 @@ export namespace WasiHttpIncomingHandler {

}
import type { IncomingRequest } from '../interfaces/wasi-http-types.js';
import type { IncomingRequest } from './wasi-http-types.js';
export { IncomingRequest };
import type { ResponseOutparam } from '../interfaces/wasi-http-types.js';
import type { ResponseOutparam } from './wasi-http-types.js';
export { ResponseOutparam };

@@ -16,9 +16,9 @@ export namespace WasiHttpOutgoingHandler {

}
import type { OutgoingRequest } from '../interfaces/wasi-http-types.js';
import type { OutgoingRequest } from './wasi-http-types.js';
export { OutgoingRequest };
import type { RequestOptions } from '../interfaces/wasi-http-types.js';
import type { RequestOptions } from './wasi-http-types.js';
export { RequestOptions };
import type { FutureIncomingResponse } from '../interfaces/wasi-http-types.js';
import type { FutureIncomingResponse } from './wasi-http-types.js';
export { FutureIncomingResponse };
import type { ErrorCode } from '../interfaces/wasi-http-types.js';
import type { ErrorCode } from './wasi-http-types.js';
export { ErrorCode };

@@ -357,11 +357,11 @@ export namespace WasiHttpTypes {

}
import type { Duration } from '../interfaces/wasi-clocks-monotonic-clock.js';
import type { Duration } from './wasi-clocks-monotonic-clock.js';
export { Duration };
import type { InputStream } from '../interfaces/wasi-io-streams.js';
import type { InputStream } from './wasi-io-streams.js';
export { InputStream };
import type { OutputStream } from '../interfaces/wasi-io-streams.js';
import type { OutputStream } from './wasi-io-streams.js';
export { OutputStream };
import type { Error as IoError } from '../interfaces/wasi-io-error.js';
import type { Error as IoError } from './wasi-io-error.js';
export { IoError };
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };

@@ -633,6 +633,2 @@ /**

export class ResponseOutparam {
static set(param: ResponseOutparam, response: Result<OutgoingResponse, ErrorCode>): void;
}
export class OutgoingResponse {

@@ -651,38 +647,18 @@ constructor(headers: Headers)

export class Fields {
constructor()
static fromList(entries: [FieldKey, FieldValue][]): Fields;
get(name: FieldKey): FieldValue[];
has(name: FieldKey): boolean;
set(name: FieldKey, value: FieldValue[]): void;
'delete'(name: FieldKey): void;
append(name: FieldKey, value: FieldValue): void;
entries(): [FieldKey, FieldValue][];
clone(): Fields;
export class IncomingResponse {
status(): StatusCode;
headers(): Headers;
consume(): IncomingBody;
}
export class IncomingBody {
stream(): InputStream;
static finish(this_: IncomingBody): FutureTrailers;
export class RequestOptions {
constructor()
connectTimeout(): Duration | undefined;
setConnectTimeout(duration: Duration | undefined): void;
firstByteTimeout(): Duration | undefined;
setFirstByteTimeout(duration: Duration | undefined): void;
betweenBytesTimeout(): Duration | undefined;
setBetweenBytesTimeout(duration: Duration | undefined): void;
}
export class FutureIncomingResponse {
subscribe(): Pollable;
get(): Result<Result<IncomingResponse, ErrorCode>, void> | undefined;
}
export class FutureTrailers {
subscribe(): Pollable;
get(): Result<Result<Trailers | undefined, ErrorCode>, void> | undefined;
}
export class IncomingRequest {
method(): Method;
pathWithQuery(): string | undefined;
scheme(): Scheme | undefined;
authority(): string | undefined;
headers(): Headers;
consume(): IncomingBody;
}
export class OutgoingRequest {

@@ -702,4 +678,7 @@ constructor(headers: Headers)

export class IncomingResponse {
status(): StatusCode;
export class IncomingRequest {
method(): Method;
pathWithQuery(): string | undefined;
scheme(): Scheme | undefined;
authority(): string | undefined;
headers(): Headers;

@@ -709,10 +688,31 @@ consume(): IncomingBody;

export class RequestOptions {
export class Fields {
constructor()
connectTimeout(): Duration | undefined;
setConnectTimeout(duration: Duration | undefined): void;
firstByteTimeout(): Duration | undefined;
setFirstByteTimeout(duration: Duration | undefined): void;
betweenBytesTimeout(): Duration | undefined;
setBetweenBytesTimeout(duration: Duration | undefined): void;
static fromList(entries: [FieldKey, FieldValue][]): Fields;
get(name: FieldKey): FieldValue[];
has(name: FieldKey): boolean;
set(name: FieldKey, value: FieldValue[]): void;
'delete'(name: FieldKey): void;
append(name: FieldKey, value: FieldValue): void;
entries(): [FieldKey, FieldValue][];
clone(): Fields;
}
export class FutureTrailers {
subscribe(): Pollable;
get(): Result<Result<Trailers | undefined, ErrorCode>, void> | undefined;
}
export class FutureIncomingResponse {
subscribe(): Pollable;
get(): Result<Result<IncomingResponse, ErrorCode>, void> | undefined;
}
export class IncomingBody {
stream(): InputStream;
static finish(this_: IncomingBody): FutureTrailers;
}
export class ResponseOutparam {
static set(param: ResponseOutparam, response: Result<OutgoingResponse, ErrorCode>): void;
}

@@ -191,5 +191,5 @@ export namespace WasiIoStreams {

}
import type { Error } from '../interfaces/wasi-io-error.js';
import type { Error } from './wasi-io-error.js';
export { Error };
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };

@@ -196,0 +196,0 @@ /**

@@ -7,3 +7,3 @@ export namespace WasiSocketsInstanceNetwork {

}
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };

@@ -48,9 +48,9 @@ export namespace WasiSocketsIpNameLookup {

}
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };
import type { ErrorCode } from '../interfaces/wasi-sockets-network.js';
import type { ErrorCode } from './wasi-sockets-network.js';
export { ErrorCode };
import type { IpAddress } from '../interfaces/wasi-sockets-network.js';
import type { IpAddress } from './wasi-sockets-network.js';
export { IpAddress };

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

@@ -26,9 +26,9 @@ export namespace WasiSocketsTcpCreateSocket {

}
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };
import type { ErrorCode } from '../interfaces/wasi-sockets-network.js';
import type { ErrorCode } from './wasi-sockets-network.js';
export { ErrorCode };
import type { IpAddressFamily } from '../interfaces/wasi-sockets-network.js';
import type { IpAddressFamily } from './wasi-sockets-network.js';
export { IpAddressFamily };
import type { TcpSocket } from '../interfaces/wasi-sockets-tcp.js';
import type { TcpSocket } from './wasi-sockets-tcp.js';
export { TcpSocket };

@@ -305,17 +305,17 @@ export namespace WasiSocketsTcp {

}
import type { InputStream } from '../interfaces/wasi-io-streams.js';
import type { InputStream } from './wasi-io-streams.js';
export { InputStream };
import type { OutputStream } from '../interfaces/wasi-io-streams.js';
import type { OutputStream } from './wasi-io-streams.js';
export { OutputStream };
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };
import type { Duration } from '../interfaces/wasi-clocks-monotonic-clock.js';
import type { Duration } from './wasi-clocks-monotonic-clock.js';
export { Duration };
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };
import type { ErrorCode } from '../interfaces/wasi-sockets-network.js';
import type { ErrorCode } from './wasi-sockets-network.js';
export { ErrorCode };
import type { IpSocketAddress } from '../interfaces/wasi-sockets-network.js';
import type { IpSocketAddress } from './wasi-sockets-network.js';
export { IpSocketAddress };
import type { IpAddressFamily } from '../interfaces/wasi-sockets-network.js';
import type { IpAddressFamily } from './wasi-sockets-network.js';
export { IpAddressFamily };

@@ -322,0 +322,0 @@ /**

@@ -26,9 +26,9 @@ export namespace WasiSocketsUdpCreateSocket {

}
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };
import type { ErrorCode } from '../interfaces/wasi-sockets-network.js';
import type { ErrorCode } from './wasi-sockets-network.js';
export { ErrorCode };
import type { IpAddressFamily } from '../interfaces/wasi-sockets-network.js';
import type { IpAddressFamily } from './wasi-sockets-network.js';
export { IpAddressFamily };
import type { UdpSocket } from '../interfaces/wasi-sockets-udp.js';
import type { UdpSocket } from './wasi-sockets-udp.js';
export { UdpSocket };

@@ -223,11 +223,11 @@ export namespace WasiSocketsUdp {

}
import type { Pollable } from '../interfaces/wasi-io-poll.js';
import type { Pollable } from './wasi-io-poll.js';
export { Pollable };
import type { Network } from '../interfaces/wasi-sockets-network.js';
import type { Network } from './wasi-sockets-network.js';
export { Network };
import type { ErrorCode } from '../interfaces/wasi-sockets-network.js';
import type { ErrorCode } from './wasi-sockets-network.js';
export { ErrorCode };
import type { IpSocketAddress } from '../interfaces/wasi-sockets-network.js';
import type { IpSocketAddress } from './wasi-sockets-network.js';
export { IpSocketAddress };
import type { IpAddressFamily } from '../interfaces/wasi-sockets-network.js';
import type { IpAddressFamily } from './wasi-sockets-network.js';
export { IpAddressFamily };

@@ -234,0 +234,0 @@ /**

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