@bytecodealliance/preview3-shim 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +220 -0
- package/README.md +14 -0
- package/lib/nodejs/cli.js +127 -0
- package/lib/nodejs/clocks.js +100 -0
- package/lib/nodejs/filesystem/descriptor.js +997 -0
- package/lib/nodejs/filesystem/error.js +92 -0
- package/lib/nodejs/filesystem/utils.js +19 -0
- package/lib/nodejs/filesystem.js +2 -0
- package/lib/nodejs/finalization.js +33 -0
- package/lib/nodejs/future.js +187 -0
- package/lib/nodejs/http/client.js +146 -0
- package/lib/nodejs/http/error.js +71 -0
- package/lib/nodejs/http/fields.js +359 -0
- package/lib/nodejs/http/request.js +589 -0
- package/lib/nodejs/http/response.js +212 -0
- package/lib/nodejs/http/server.js +157 -0
- package/lib/nodejs/http.js +34 -0
- package/lib/nodejs/index.js +8 -0
- package/lib/nodejs/random.js +14 -0
- package/lib/nodejs/sockets/address.js +146 -0
- package/lib/nodejs/sockets/error.js +123 -0
- package/lib/nodejs/sockets/ip-name-lookup.js +93 -0
- package/lib/nodejs/sockets/tcp.js +776 -0
- package/lib/nodejs/sockets/udp.js +516 -0
- package/lib/nodejs/sockets.js +14 -0
- package/lib/nodejs/stream.js +423 -0
- package/lib/nodejs/workers/cli-worker.js +49 -0
- package/lib/nodejs/workers/filesystem-worker.js +119 -0
- package/lib/nodejs/workers/http-worker.js +387 -0
- package/lib/nodejs/workers/resource-worker.js +151 -0
- package/lib/nodejs/workers/tcp-worker.js +283 -0
- package/lib/nodejs/workers/udp-worker.js +194 -0
- package/package.json +57 -0
- package/types/cli.d.ts +12 -0
- package/types/clocks.d.ts +2 -0
- package/types/filesystem.d.ts +2 -0
- package/types/http.d.ts +4 -0
- package/types/index.d.ts +6 -0
- package/types/interfaces/wasi-cli-environment.d.ts +21 -0
- package/types/interfaces/wasi-cli-exit.d.ts +6 -0
- package/types/interfaces/wasi-cli-run.d.ts +5 -0
- package/types/interfaces/wasi-cli-stderr.d.ts +14 -0
- package/types/interfaces/wasi-cli-stdin.d.ts +19 -0
- package/types/interfaces/wasi-cli-stdout.d.ts +14 -0
- package/types/interfaces/wasi-cli-terminal-input.d.ts +8 -0
- package/types/interfaces/wasi-cli-terminal-output.d.ts +8 -0
- package/types/interfaces/wasi-cli-terminal-stderr.d.ts +7 -0
- package/types/interfaces/wasi-cli-terminal-stdin.d.ts +7 -0
- package/types/interfaces/wasi-cli-terminal-stdout.d.ts +7 -0
- package/types/interfaces/wasi-cli-types.d.ts +15 -0
- package/types/interfaces/wasi-clocks-monotonic-clock.d.ts +33 -0
- package/types/interfaces/wasi-clocks-system-clock.d.ts +38 -0
- package/types/interfaces/wasi-clocks-types.d.ts +5 -0
- package/types/interfaces/wasi-filesystem-preopens.d.ts +6 -0
- package/types/interfaces/wasi-filesystem-types.d.ts +780 -0
- package/types/interfaces/wasi-http-client.d.ts +9 -0
- package/types/interfaces/wasi-http-handler.d.ts +9 -0
- package/types/interfaces/wasi-http-types.d.ts +619 -0
- package/types/interfaces/wasi-random-insecure-seed.d.ts +21 -0
- package/types/interfaces/wasi-random-insecure.d.ts +26 -0
- package/types/interfaces/wasi-random-random.d.ts +31 -0
- package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +77 -0
- package/types/interfaces/wasi-sockets-types.d.ts +830 -0
- package/types/random.d.ts +3 -0
- package/types/sockets.d.ts +2 -0
- package/types/wasi-cli-command.d.ts +23 -0
- package/types/wasi-http-service.d.ts +14 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @module Interface wasi:random/random@0.3.0-rc-2026-03-15 **/
|
|
2
|
+
/**
|
|
3
|
+
* Return up to `max-len` cryptographically-secure random or pseudo-random
|
|
4
|
+
* bytes.
|
|
5
|
+
*
|
|
6
|
+
* This function must produce data at least as cryptographically secure and
|
|
7
|
+
* fast as an adequately seeded cryptographically-secure pseudo-random
|
|
8
|
+
* number generator (CSPRNG). It must not block, from the perspective of
|
|
9
|
+
* the calling program, under any circumstances, including on the first
|
|
10
|
+
* request and on requests for numbers of bytes. The returned data must
|
|
11
|
+
* always be unpredictable.
|
|
12
|
+
*
|
|
13
|
+
* Implementations MAY return fewer bytes than requested (a short read).
|
|
14
|
+
* Callers that require exactly `max-len` bytes MUST call this function in
|
|
15
|
+
* a loop until the desired number of bytes has been accumulated.
|
|
16
|
+
* Implementations MUST return at least 1 byte when `max-len` is greater
|
|
17
|
+
* than zero. When `max-len` is zero, implementations MUST return an empty
|
|
18
|
+
* list without trapping.
|
|
19
|
+
*
|
|
20
|
+
* This function must always return fresh data. Deterministic environments
|
|
21
|
+
* must omit this function, rather than implementing it with deterministic
|
|
22
|
+
* data.
|
|
23
|
+
*/
|
|
24
|
+
export function getRandomBytes(maxLen: bigint): Uint8Array;
|
|
25
|
+
/**
|
|
26
|
+
* Return a cryptographically-secure random or pseudo-random `u64` value.
|
|
27
|
+
*
|
|
28
|
+
* This function returns the same type of data as `get-random-bytes`,
|
|
29
|
+
* represented as a `u64`.
|
|
30
|
+
*/
|
|
31
|
+
export function getRandomU64(): bigint;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** @module Interface wasi:sockets/ip-name-lookup@0.3.0-rc-2026-03-15 **/
|
|
2
|
+
/**
|
|
3
|
+
* Resolve an internet host name to a list of IP addresses.
|
|
4
|
+
*
|
|
5
|
+
* Unicode domain names are automatically converted to ASCII using IDNA
|
|
6
|
+
* encoding. If the input is an IP address string, the address is parsed
|
|
7
|
+
* and returned as-is without making any external requests.
|
|
8
|
+
*
|
|
9
|
+
* See the wasi-socket proposal README.md for a comparison with getaddrinfo.
|
|
10
|
+
*
|
|
11
|
+
* The results are returned in connection order preference.
|
|
12
|
+
*
|
|
13
|
+
* This function never succeeds with 0 results. It either fails or succeeds
|
|
14
|
+
* with at least one address. Additionally, this function never returns
|
|
15
|
+
* IPv4-mapped IPv6 addresses.
|
|
16
|
+
*
|
|
17
|
+
* # References:
|
|
18
|
+
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
|
|
19
|
+
* - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
|
|
20
|
+
* - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
|
|
21
|
+
* - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
|
|
22
|
+
*/
|
|
23
|
+
export function resolveAddresses(name: string): Promise<Array<IpAddress>>;
|
|
24
|
+
export type IpAddress = import('./wasi-sockets-types.js').IpAddress;
|
|
25
|
+
/**
|
|
26
|
+
* Lookup error codes.
|
|
27
|
+
*/
|
|
28
|
+
export type ErrorCode = ErrorCodeAccessDenied | ErrorCodeInvalidArgument | ErrorCodeNameUnresolvable | ErrorCodeTemporaryResolverFailure | ErrorCodePermanentResolverFailure | ErrorCodeOther;
|
|
29
|
+
/**
|
|
30
|
+
* Access denied.
|
|
31
|
+
*
|
|
32
|
+
* POSIX equivalent: EACCES, EPERM
|
|
33
|
+
*/
|
|
34
|
+
export interface ErrorCodeAccessDenied {
|
|
35
|
+
tag: 'access-denied',
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `name` is a syntactically invalid domain name or IP address.
|
|
39
|
+
*
|
|
40
|
+
* POSIX equivalent: EINVAL
|
|
41
|
+
*/
|
|
42
|
+
export interface ErrorCodeInvalidArgument {
|
|
43
|
+
tag: 'invalid-argument',
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Name does not exist or has no suitable associated IP addresses.
|
|
47
|
+
*
|
|
48
|
+
* POSIX equivalent: EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY
|
|
49
|
+
*/
|
|
50
|
+
export interface ErrorCodeNameUnresolvable {
|
|
51
|
+
tag: 'name-unresolvable',
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A temporary failure in name resolution occurred.
|
|
55
|
+
*
|
|
56
|
+
* POSIX equivalent: EAI_AGAIN
|
|
57
|
+
*/
|
|
58
|
+
export interface ErrorCodeTemporaryResolverFailure {
|
|
59
|
+
tag: 'temporary-resolver-failure',
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A permanent failure in name resolution occurred.
|
|
63
|
+
*
|
|
64
|
+
* POSIX equivalent: EAI_FAIL
|
|
65
|
+
*/
|
|
66
|
+
export interface ErrorCodePermanentResolverFailure {
|
|
67
|
+
tag: 'permanent-resolver-failure',
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A catch-all for errors not captured by the existing variants.
|
|
71
|
+
* Implementations can use this to extend the error type without
|
|
72
|
+
* breaking existing code.
|
|
73
|
+
*/
|
|
74
|
+
export interface ErrorCodeOther {
|
|
75
|
+
tag: 'other',
|
|
76
|
+
val: string | undefined,
|
|
77
|
+
}
|