@bytecodealliance/preview2-shim 0.17.1 → 0.17.2

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.
Files changed (43) hide show
  1. package/lib/io/worker-thread.js +64 -12
  2. package/package.json +1 -1
  3. package/types/cli.d.ts +11 -23
  4. package/types/clocks.d.ts +2 -5
  5. package/types/filesystem.d.ts +2 -5
  6. package/types/http.d.ts +3 -7
  7. package/types/index.d.ts +7 -15
  8. package/types/interfaces/wasi-cli-environment.d.ts +21 -22
  9. package/types/interfaces/wasi-cli-exit.d.ts +5 -6
  10. package/types/interfaces/wasi-cli-run.d.ts +5 -6
  11. package/types/interfaces/wasi-cli-stderr.d.ts +3 -5
  12. package/types/interfaces/wasi-cli-stdin.d.ts +3 -5
  13. package/types/interfaces/wasi-cli-stdout.d.ts +3 -5
  14. package/types/interfaces/wasi-cli-terminal-input.d.ts +5 -3
  15. package/types/interfaces/wasi-cli-terminal-output.d.ts +5 -3
  16. package/types/interfaces/wasi-cli-terminal-stderr.d.ts +7 -9
  17. package/types/interfaces/wasi-cli-terminal-stdin.d.ts +7 -9
  18. package/types/interfaces/wasi-cli-terminal-stdout.d.ts +7 -9
  19. package/types/interfaces/wasi-clocks-monotonic-clock.d.ts +24 -26
  20. package/types/interfaces/wasi-clocks-wall-clock.d.ts +23 -24
  21. package/types/interfaces/wasi-filesystem-preopens.d.ts +6 -8
  22. package/types/interfaces/wasi-filesystem-types.d.ts +34 -33
  23. package/types/interfaces/wasi-http-incoming-handler.d.ts +16 -19
  24. package/types/interfaces/wasi-http-outgoing-handler.d.ts +18 -23
  25. package/types/interfaces/wasi-http-types.d.ts +49 -38
  26. package/types/interfaces/wasi-io-error.d.ts +5 -3
  27. package/types/interfaces/wasi-io-poll.d.ts +27 -25
  28. package/types/interfaces/wasi-io-streams.d.ts +24 -21
  29. package/types/interfaces/wasi-random-insecure-seed.d.ts +21 -22
  30. package/types/interfaces/wasi-random-insecure.d.ts +19 -20
  31. package/types/interfaces/wasi-random-random.d.ts +23 -24
  32. package/types/interfaces/wasi-sockets-instance-network.d.ts +6 -8
  33. package/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +32 -34
  34. package/types/interfaces/wasi-sockets-network.d.ts +5 -3
  35. package/types/interfaces/wasi-sockets-tcp-create-socket.d.ts +28 -33
  36. package/types/interfaces/wasi-sockets-tcp.d.ts +17 -23
  37. package/types/interfaces/wasi-sockets-udp-create-socket.d.ts +28 -33
  38. package/types/interfaces/wasi-sockets-udp.d.ts +20 -17
  39. package/types/io.d.ts +3 -7
  40. package/types/random.d.ts +3 -7
  41. package/types/sockets.d.ts +7 -15
  42. package/types/wasi-cli-command.d.ts +29 -29
  43. package/types/wasi-http-proxy.d.ts +13 -13
@@ -1,19 +1,16 @@
1
- export namespace WasiHttpIncomingHandler {
2
- /**
3
- * This function is invoked with an incoming HTTP Request, and a resource
4
- * `response-outparam` which provides the capability to reply with an HTTP
5
- * Response. The response is sent by calling the `response-outparam.set`
6
- * method, which allows execution to continue after the response has been
7
- * sent. This enables both streaming to the response body, and performing other
8
- * work.
9
- *
10
- * The implementor of this function must write a response to the
11
- * `response-outparam` before returning, or else the caller will respond
12
- * with an error on its behalf.
13
- */
14
- export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
15
- }
16
- import type { IncomingRequest } from './wasi-http-types.js';
17
- export { IncomingRequest };
18
- import type { ResponseOutparam } from './wasi-http-types.js';
19
- export { ResponseOutparam };
1
+ /** @module Interface wasi:http/incoming-handler@0.2.3 **/
2
+ /**
3
+ * This function is invoked with an incoming HTTP Request, and a resource
4
+ * `response-outparam` which provides the capability to reply with an HTTP
5
+ * Response. The response is sent by calling the `response-outparam.set`
6
+ * method, which allows execution to continue after the response has been
7
+ * sent. This enables both streaming to the response body, and performing other
8
+ * work.
9
+ *
10
+ * The implementor of this function must write a response to the
11
+ * `response-outparam` before returning, or else the caller will respond
12
+ * with an error on its behalf.
13
+ */
14
+ export function handle(request: IncomingRequest, responseOut: ResponseOutparam): void;
15
+ export type IncomingRequest = import('./wasi-http-types.js').IncomingRequest;
16
+ export type ResponseOutparam = import('./wasi-http-types.js').ResponseOutparam;
@@ -1,23 +1,18 @@
1
- export namespace WasiHttpOutgoingHandler {
2
- /**
3
- * This function is invoked with an outgoing HTTP Request, and it returns
4
- * a resource `future-incoming-response` which represents an HTTP Response
5
- * which may arrive in the future.
6
- *
7
- * The `options` argument accepts optional parameters for the HTTP
8
- * protocol's transport layer.
9
- *
10
- * This function may return an error if the `outgoing-request` is invalid
11
- * or not allowed to be made. Otherwise, protocol errors are reported
12
- * through the `future-incoming-response`.
13
- */
14
- export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
15
- }
16
- import type { OutgoingRequest } from './wasi-http-types.js';
17
- export { OutgoingRequest };
18
- import type { RequestOptions } from './wasi-http-types.js';
19
- export { RequestOptions };
20
- import type { FutureIncomingResponse } from './wasi-http-types.js';
21
- export { FutureIncomingResponse };
22
- import type { ErrorCode } from './wasi-http-types.js';
23
- export { ErrorCode };
1
+ /** @module Interface wasi:http/outgoing-handler@0.2.3 **/
2
+ /**
3
+ * This function is invoked with an outgoing HTTP Request, and it returns
4
+ * a resource `future-incoming-response` which represents an HTTP Response
5
+ * which may arrive in the future.
6
+ *
7
+ * The `options` argument accepts optional parameters for the HTTP
8
+ * protocol's transport layer.
9
+ *
10
+ * This function may return an error if the `outgoing-request` is invalid
11
+ * or not allowed to be made. Otherwise, protocol errors are reported
12
+ * through the `future-incoming-response`.
13
+ */
14
+ export function handle(request: OutgoingRequest, options: RequestOptions | undefined): FutureIncomingResponse;
15
+ export type OutgoingRequest = import('./wasi-http-types.js').OutgoingRequest;
16
+ export type RequestOptions = import('./wasi-http-types.js').RequestOptions;
17
+ export type FutureIncomingResponse = import('./wasi-http-types.js').FutureIncomingResponse;
18
+ export type ErrorCode = import('./wasi-http-types.js').ErrorCode;
@@ -1,40 +1,23 @@
1
- export namespace WasiHttpTypes {
2
- /**
3
- * Attempts to extract a http-related `error` from the wasi:io `error`
4
- * provided.
5
- *
6
- * Stream operations which return
7
- * `wasi:io/stream/stream-error::last-operation-failed` have a payload of
8
- * type `wasi:io/error/error` with more information about the operation
9
- * that failed. This payload can be passed through to this function to see
10
- * if there's http-related information about the error to return.
11
- *
12
- * Note that this function is fallible because not all io-errors are
13
- * http-related errors.
14
- */
15
- export function httpErrorCode(err: IoError): ErrorCode | undefined;
16
- export { Fields };
17
- export { IncomingRequest };
18
- export { OutgoingRequest };
19
- export { RequestOptions };
20
- export { ResponseOutparam };
21
- export { IncomingResponse };
22
- export { IncomingBody };
23
- export { FutureTrailers };
24
- export { OutgoingResponse };
25
- export { OutgoingBody };
26
- export { FutureIncomingResponse };
27
- }
28
- import type { Duration } from './wasi-clocks-monotonic-clock.js';
29
- export { Duration };
30
- import type { InputStream } from './wasi-io-streams.js';
31
- export { InputStream };
32
- import type { OutputStream } from './wasi-io-streams.js';
33
- export { OutputStream };
34
- import type { Error as IoError } from './wasi-io-error.js';
35
- export { IoError };
36
- import type { Pollable } from './wasi-io-poll.js';
37
- export { Pollable };
1
+ /** @module Interface wasi:http/types@0.2.3 **/
2
+ /**
3
+ * Attempts to extract a http-related `error` from the wasi:io `error`
4
+ * provided.
5
+ *
6
+ * Stream operations which return
7
+ * `wasi:io/stream/stream-error::last-operation-failed` have a payload of
8
+ * type `wasi:io/error/error` with more information about the operation
9
+ * that failed. This payload can be passed through to this function to see
10
+ * if there's http-related information about the error to return.
11
+ *
12
+ * Note that this function is fallible because not all io-errors are
13
+ * http-related errors.
14
+ */
15
+ export function httpErrorCode(err: IoError): ErrorCode | undefined;
16
+ export type Duration = import('./wasi-clocks-monotonic-clock.js').Duration;
17
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
18
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
19
+ export type IoError = import('./wasi-io-error.js').Error;
20
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
38
21
  /**
39
22
  * This type corresponds to HTTP standard Methods.
40
23
  */
@@ -107,7 +90,7 @@ export interface FieldSizePayload {
107
90
  }
108
91
  /**
109
92
  * These cases are inspired by the IANA HTTP Proxy Error Types:
110
- * https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types
93
+ * <https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types>
111
94
  */
112
95
  export type ErrorCode = ErrorCodeDnsTimeout | ErrorCodeDnsError | ErrorCodeDestinationNotFound | ErrorCodeDestinationUnavailable | ErrorCodeDestinationIpProhibited | ErrorCodeDestinationIpUnroutable | ErrorCodeConnectionRefused | ErrorCodeConnectionTerminated | ErrorCodeConnectionTimeout | ErrorCodeConnectionReadTimeout | ErrorCodeConnectionWriteTimeout | ErrorCodeConnectionLimitReached | ErrorCodeTlsProtocolError | ErrorCodeTlsCertificateError | ErrorCodeTlsAlertReceived | ErrorCodeHttpRequestDenied | ErrorCodeHttpRequestLengthRequired | ErrorCodeHttpRequestBodySize | ErrorCodeHttpRequestMethodInvalid | ErrorCodeHttpRequestUriInvalid | ErrorCodeHttpRequestUriTooLong | ErrorCodeHttpRequestHeaderSectionSize | ErrorCodeHttpRequestHeaderSize | ErrorCodeHttpRequestTrailerSectionSize | ErrorCodeHttpRequestTrailerSize | ErrorCodeHttpResponseIncomplete | ErrorCodeHttpResponseHeaderSectionSize | ErrorCodeHttpResponseHeaderSize | ErrorCodeHttpResponseBodySize | ErrorCodeHttpResponseTrailerSectionSize | ErrorCodeHttpResponseTrailerSize | ErrorCodeHttpResponseTransferCoding | ErrorCodeHttpResponseContentCoding | ErrorCodeHttpResponseTimeout | ErrorCodeHttpUpgradeFailed | ErrorCodeHttpProtocolError | ErrorCodeLoopDetected | ErrorCodeConfigurationError | ErrorCodeInternalError;
113
96
  export interface ErrorCodeDnsTimeout {
@@ -400,6 +383,10 @@ export class Fields {
400
383
  }
401
384
 
402
385
  export class FutureIncomingResponse {
386
+ /**
387
+ * This type does not have a public constructor.
388
+ */
389
+ private constructor();
403
390
  /**
404
391
  * Returns a pollable which becomes ready when either the Response has
405
392
  * been received, or an error has occurred. When this pollable is ready,
@@ -426,6 +413,10 @@ export class FutureIncomingResponse {
426
413
  }
427
414
 
428
415
  export class FutureTrailers {
416
+ /**
417
+ * This type does not have a public constructor.
418
+ */
419
+ private constructor();
429
420
  /**
430
421
  * Returns a pollable which becomes ready when either the trailers have
431
422
  * been received, or an error has occurred. When this pollable is ready,
@@ -457,6 +448,10 @@ export class FutureTrailers {
457
448
  }
458
449
 
459
450
  export class IncomingBody {
451
+ /**
452
+ * This type does not have a public constructor.
453
+ */
454
+ private constructor();
460
455
  /**
461
456
  * Returns the contents of the body, as a stream of bytes.
462
457
  *
@@ -483,6 +478,10 @@ export class IncomingBody {
483
478
  }
484
479
 
485
480
  export class IncomingRequest {
481
+ /**
482
+ * This type does not have a public constructor.
483
+ */
484
+ private constructor();
486
485
  /**
487
486
  * Returns the method of the incoming request.
488
487
  */
@@ -518,6 +517,10 @@ export class IncomingRequest {
518
517
  }
519
518
 
520
519
  export class IncomingResponse {
520
+ /**
521
+ * This type does not have a public constructor.
522
+ */
523
+ private constructor();
521
524
  /**
522
525
  * Returns the status code from the incoming response.
523
526
  */
@@ -540,6 +543,10 @@ export class IncomingResponse {
540
543
  }
541
544
 
542
545
  export class OutgoingBody {
546
+ /**
547
+ * This type does not have a public constructor.
548
+ */
549
+ private constructor();
543
550
  /**
544
551
  * Returns a stream for writing the body contents.
545
552
  *
@@ -722,6 +729,10 @@ export class RequestOptions {
722
729
  }
723
730
 
724
731
  export class ResponseOutparam {
732
+ /**
733
+ * This type does not have a public constructor.
734
+ */
735
+ private constructor();
725
736
  /**
726
737
  * Set the value of the `response-outparam` to either send a response,
727
738
  * or indicate an error.
@@ -1,8 +1,10 @@
1
- export namespace WasiIoError {
2
- export { Error };
3
- }
1
+ /** @module Interface wasi:io/error@0.2.3 **/
4
2
 
5
3
  export class Error {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
6
8
  /**
7
9
  * Returns a string that is suitable to assist humans in debugging
8
10
  * this error.
@@ -1,30 +1,32 @@
1
- export namespace WasiIoPoll {
2
- export { Pollable };
3
- /**
4
- * Poll for completion on a set of pollables.
5
- *
6
- * This function takes a list of pollables, which identify I/O sources of
7
- * interest, and waits until one or more of the events is ready for I/O.
8
- *
9
- * The result `list<u32>` contains one or more indices of handles in the
10
- * argument list that is ready for I/O.
11
- *
12
- * This function traps if either:
13
- * - the list is empty, or:
14
- * - the list contains more elements than can be indexed with a `u32` value.
15
- *
16
- * A timeout can be implemented by adding a pollable from the
17
- * wasi-clocks API to the list.
18
- *
19
- * This function does not return a `result`; polling in itself does not
20
- * do any I/O so it doesn't fail. If any of the I/O sources identified by
21
- * the pollables has an error, it is indicated by marking the source as
22
- * being ready for I/O.
23
- */
24
- export function poll(in_: Array<Pollable>): Uint32Array;
25
- }
1
+ /** @module Interface wasi:io/poll@0.2.3 **/
2
+ /**
3
+ * Poll for completion on a set of pollables.
4
+ *
5
+ * This function takes a list of pollables, which identify I/O sources of
6
+ * interest, and waits until one or more of the events is ready for I/O.
7
+ *
8
+ * The result `list<u32>` contains one or more indices of handles in the
9
+ * argument list that is ready for I/O.
10
+ *
11
+ * This function traps if either:
12
+ * - the list is empty, or:
13
+ * - the list contains more elements than can be indexed with a `u32` value.
14
+ *
15
+ * A timeout can be implemented by adding a pollable from the
16
+ * wasi-clocks API to the list.
17
+ *
18
+ * This function does not return a `result`; polling in itself does not
19
+ * do any I/O so it doesn't fail. If any of the I/O sources identified by
20
+ * the pollables has an error, it is indicated by marking the source as
21
+ * being ready for I/O.
22
+ */
23
+ export function poll(in_: Array<Pollable>): Uint32Array;
26
24
 
27
25
  export class Pollable {
26
+ /**
27
+ * This type does not have a public constructor.
28
+ */
29
+ private constructor();
28
30
  /**
29
31
  * Return the readiness of a pollable. This function never blocks.
30
32
  *
@@ -1,11 +1,6 @@
1
- export namespace WasiIoStreams {
2
- export { InputStream };
3
- export { OutputStream };
4
- }
5
- import type { Error } from './wasi-io-error.js';
6
- export { Error };
7
- import type { Pollable } from './wasi-io-poll.js';
8
- export { Pollable };
1
+ /** @module Interface wasi:io/streams@0.2.3 **/
2
+ export type Error = import('./wasi-io-error.js').Error;
3
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
9
4
  /**
10
5
  * An error for input-stream and output-stream operations.
11
6
  */
@@ -32,6 +27,10 @@ export interface StreamErrorClosed {
32
27
  }
33
28
 
34
29
  export class InputStream {
30
+ /**
31
+ * This type does not have a public constructor.
32
+ */
33
+ private constructor();
35
34
  /**
36
35
  * Perform a non-blocking read from the stream.
37
36
  *
@@ -90,6 +89,10 @@ export class InputStream {
90
89
  }
91
90
 
92
91
  export class OutputStream {
92
+ /**
93
+ * This type does not have a public constructor.
94
+ */
95
+ private constructor();
93
96
  /**
94
97
  * Check readiness for writing. This function never blocks.
95
98
  *
@@ -129,13 +132,13 @@ export class OutputStream {
129
132
  * ```text
130
133
  * let pollable = this.subscribe();
131
134
  * while !contents.is_empty() {
132
- * // Wait for the stream to become writable
133
- * pollable.block();
134
- * let Ok(n) = this.check-write(); // eliding error handling
135
- * let len = min(n, contents.len());
136
- * let (chunk, rest) = contents.split_at(len);
137
- * this.write(chunk ); // eliding error handling
138
- * contents = rest;
135
+ * // Wait for the stream to become writable
136
+ * pollable.block();
137
+ * let Ok(n) = this.check-write(); // eliding error handling
138
+ * let len = min(n, contents.len());
139
+ * let (chunk, rest) = contents.split_at(len);
140
+ * this.write(chunk ); // eliding error handling
141
+ * contents = rest;
139
142
  * }
140
143
  * this.flush();
141
144
  * // Wait for completion of `flush`
@@ -197,12 +200,12 @@ export class OutputStream {
197
200
  * ```text
198
201
  * let pollable = this.subscribe();
199
202
  * while num_zeroes != 0 {
200
- * // Wait for the stream to become writable
201
- * pollable.block();
202
- * let Ok(n) = this.check-write(); // eliding error handling
203
- * let len = min(n, num_zeroes);
204
- * this.write-zeroes(len); // eliding error handling
205
- * num_zeroes -= len;
203
+ * // Wait for the stream to become writable
204
+ * pollable.block();
205
+ * let Ok(n) = this.check-write(); // eliding error handling
206
+ * let len = min(n, num_zeroes);
207
+ * this.write-zeroes(len); // eliding error handling
208
+ * num_zeroes -= len;
206
209
  * }
207
210
  * this.flush();
208
211
  * // Wait for completion of `flush`
@@ -1,22 +1,21 @@
1
- export namespace WasiRandomInsecureSeed {
2
- /**
3
- * Return a 128-bit value that may contain a pseudo-random value.
4
- *
5
- * The returned value is not required to be computed from a CSPRNG, and may
6
- * even be entirely deterministic. Host implementations are encouraged to
7
- * provide pseudo-random values to any program exposed to
8
- * attacker-controlled content, to enable DoS protection built into many
9
- * languages' hash-map implementations.
10
- *
11
- * This function is intended to only be called once, by a source language
12
- * to initialize Denial Of Service (DoS) protection in its hash-map
13
- * implementation.
14
- *
15
- * # Expected future evolution
16
- *
17
- * This will likely be changed to a value import, to prevent it from being
18
- * called multiple times and potentially used for purposes other than DoS
19
- * protection.
20
- */
21
- export function insecureSeed(): [bigint, bigint];
22
- }
1
+ /** @module Interface wasi:random/insecure-seed@0.2.3 **/
2
+ /**
3
+ * Return a 128-bit value that may contain a pseudo-random value.
4
+ *
5
+ * The returned value is not required to be computed from a CSPRNG, and may
6
+ * even be entirely deterministic. Host implementations are encouraged to
7
+ * provide pseudo-random values to any program exposed to
8
+ * attacker-controlled content, to enable DoS protection built into many
9
+ * languages' hash-map implementations.
10
+ *
11
+ * This function is intended to only be called once, by a source language
12
+ * to initialize Denial Of Service (DoS) protection in its hash-map
13
+ * implementation.
14
+ *
15
+ * # Expected future evolution
16
+ *
17
+ * This will likely be changed to a value import, to prevent it from being
18
+ * called multiple times and potentially used for purposes other than DoS
19
+ * protection.
20
+ */
21
+ export function insecureSeed(): [bigint, bigint];
@@ -1,20 +1,19 @@
1
- export namespace WasiRandomInsecure {
2
- /**
3
- * Return `len` insecure pseudo-random bytes.
4
- *
5
- * This function is not cryptographically secure. Do not use it for
6
- * anything related to security.
7
- *
8
- * There are no requirements on the values of the returned bytes, however
9
- * implementations are encouraged to return evenly distributed values with
10
- * a long period.
11
- */
12
- export function getInsecureRandomBytes(len: bigint): Uint8Array;
13
- /**
14
- * Return an insecure pseudo-random `u64` value.
15
- *
16
- * This function returns the same type of pseudo-random data as
17
- * `get-insecure-random-bytes`, represented as a `u64`.
18
- */
19
- export function getInsecureRandomU64(): bigint;
20
- }
1
+ /** @module Interface wasi:random/insecure@0.2.3 **/
2
+ /**
3
+ * Return `len` insecure pseudo-random bytes.
4
+ *
5
+ * This function is not cryptographically secure. Do not use it for
6
+ * anything related to security.
7
+ *
8
+ * There are no requirements on the values of the returned bytes, however
9
+ * implementations are encouraged to return evenly distributed values with
10
+ * a long period.
11
+ */
12
+ export function getInsecureRandomBytes(len: bigint): Uint8Array;
13
+ /**
14
+ * Return an insecure pseudo-random `u64` value.
15
+ *
16
+ * This function returns the same type of pseudo-random data as
17
+ * `get-insecure-random-bytes`, represented as a `u64`.
18
+ */
19
+ export function getInsecureRandomU64(): bigint;
@@ -1,24 +1,23 @@
1
- export namespace WasiRandomRandom {
2
- /**
3
- * Return `len` cryptographically-secure random or pseudo-random bytes.
4
- *
5
- * This function must produce data at least as cryptographically secure and
6
- * fast as an adequately seeded cryptographically-secure pseudo-random
7
- * number generator (CSPRNG). It must not block, from the perspective of
8
- * the calling program, under any circumstances, including on the first
9
- * request and on requests for numbers of bytes. The returned data must
10
- * always be unpredictable.
11
- *
12
- * This function must always return fresh data. Deterministic environments
13
- * must omit this function, rather than implementing it with deterministic
14
- * data.
15
- */
16
- export function getRandomBytes(len: bigint): Uint8Array;
17
- /**
18
- * Return a cryptographically-secure random or pseudo-random `u64` value.
19
- *
20
- * This function returns the same type of data as `get-random-bytes`,
21
- * represented as a `u64`.
22
- */
23
- export function getRandomU64(): bigint;
24
- }
1
+ /** @module Interface wasi:random/random@0.2.3 **/
2
+ /**
3
+ * Return `len` cryptographically-secure random or pseudo-random bytes.
4
+ *
5
+ * This function must produce data at least as cryptographically secure and
6
+ * fast as an adequately seeded cryptographically-secure pseudo-random
7
+ * number generator (CSPRNG). It must not block, from the perspective of
8
+ * the calling program, under any circumstances, including on the first
9
+ * request and on requests for numbers of bytes. The returned data must
10
+ * always be unpredictable.
11
+ *
12
+ * This function must always return fresh data. Deterministic environments
13
+ * must omit this function, rather than implementing it with deterministic
14
+ * data.
15
+ */
16
+ export function getRandomBytes(len: bigint): Uint8Array;
17
+ /**
18
+ * Return a cryptographically-secure random or pseudo-random `u64` value.
19
+ *
20
+ * This function returns the same type of data as `get-random-bytes`,
21
+ * represented as a `u64`.
22
+ */
23
+ export function getRandomU64(): bigint;
@@ -1,8 +1,6 @@
1
- export namespace WasiSocketsInstanceNetwork {
2
- /**
3
- * Get a handle to the default network.
4
- */
5
- export function instanceNetwork(): Network;
6
- }
7
- import type { Network } from './wasi-sockets-network.js';
8
- export { Network };
1
+ /** @module Interface wasi:sockets/instance-network@0.2.3 **/
2
+ /**
3
+ * Get a handle to the default network.
4
+ */
5
+ export function instanceNetwork(): Network;
6
+ export type Network = import('./wasi-sockets-network.js').Network;
@@ -1,39 +1,37 @@
1
- export namespace WasiSocketsIpNameLookup {
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 encoding.
6
- * If the input is an IP address string, the address is parsed and returned
7
- * as-is without making any external requests.
8
- *
9
- * See the wasi-socket proposal README.md for a comparison with getaddrinfo.
10
- *
11
- * This function never blocks. It either immediately fails or immediately
12
- * returns successfully with a `resolve-address-stream` that can be used
13
- * to (asynchronously) fetch the results.
14
- *
15
- * # Typical errors
16
- * - `invalid-argument`: `name` is a syntactically invalid domain name or IP address.
17
- *
18
- * # References:
19
- * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
20
- * - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
21
- * - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
22
- * - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
23
- */
24
- export function resolveAddresses(network: Network, name: string): ResolveAddressStream;
25
- export { ResolveAddressStream };
26
- }
27
- import type { Pollable } from './wasi-io-poll.js';
28
- export { Pollable };
29
- import type { Network } from './wasi-sockets-network.js';
30
- export { Network };
31
- import type { ErrorCode } from './wasi-sockets-network.js';
32
- export { ErrorCode };
33
- import type { IpAddress } from './wasi-sockets-network.js';
34
- export { IpAddress };
1
+ /** @module Interface wasi:sockets/ip-name-lookup@0.2.3 **/
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 encoding.
6
+ * If the input is an IP address string, the address is parsed and returned
7
+ * as-is without making any external requests.
8
+ *
9
+ * See the wasi-socket proposal README.md for a comparison with getaddrinfo.
10
+ *
11
+ * This function never blocks. It either immediately fails or immediately
12
+ * returns successfully with a `resolve-address-stream` that can be used
13
+ * to (asynchronously) fetch the results.
14
+ *
15
+ * # Typical errors
16
+ * - `invalid-argument`: `name` is a syntactically invalid domain name or IP address.
17
+ *
18
+ * # References:
19
+ * - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
20
+ * - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
21
+ * - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
22
+ * - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
23
+ */
24
+ export function resolveAddresses(network: Network, name: string): ResolveAddressStream;
25
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
26
+ export type Network = import('./wasi-sockets-network.js').Network;
27
+ export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
28
+ export type IpAddress = import('./wasi-sockets-network.js').IpAddress;
35
29
 
36
30
  export class ResolveAddressStream {
31
+ /**
32
+ * This type does not have a public constructor.
33
+ */
34
+ private constructor();
37
35
  /**
38
36
  * Returns the next address from the resolver.
39
37
  *
@@ -1,6 +1,4 @@
1
- export namespace WasiSocketsNetwork {
2
- export { Network };
3
- }
1
+ /** @module Interface wasi:sockets/network@0.2.3 **/
4
2
  /**
5
3
  * Error codes.
6
4
  *
@@ -159,4 +157,8 @@ export interface IpSocketAddressIpv6 {
159
157
  }
160
158
 
161
159
  export class Network {
160
+ /**
161
+ * This type does not have a public constructor.
162
+ */
163
+ private constructor();
162
164
  }