@cosmonic-labs/openapi2mcp 0.10.0 → 0.10.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.
- package/dist/interfaces/wasi-cli-environment.d.ts +1 -1
- package/dist/interfaces/wasi-cli-exit.d.ts +1 -1
- package/dist/interfaces/wasi-cli-stderr.d.ts +1 -1
- package/dist/interfaces/wasi-cli-stdin.d.ts +1 -1
- package/dist/interfaces/wasi-cli-stdout.d.ts +1 -1
- package/dist/interfaces/wasi-cli-terminal-input.d.ts +1 -1
- package/dist/interfaces/wasi-cli-terminal-output.d.ts +1 -1
- package/dist/interfaces/wasi-cli-terminal-stderr.d.ts +1 -1
- package/dist/interfaces/wasi-cli-terminal-stdin.d.ts +1 -1
- package/dist/interfaces/wasi-cli-terminal-stdout.d.ts +1 -1
- package/dist/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
- package/dist/interfaces/wasi-clocks-wall-clock.d.ts +1 -1
- package/dist/interfaces/wasi-filesystem-preopens.d.ts +1 -1
- package/dist/interfaces/wasi-filesystem-types.d.ts +1 -1
- package/dist/interfaces/wasi-io-error.d.ts +1 -1
- package/dist/interfaces/wasi-io-poll.d.ts +2 -1
- package/dist/interfaces/wasi-io-streams.d.ts +2 -2
- package/dist/interfaces/wasi-random-insecure-seed.d.ts +1 -1
- package/dist/openapi2mcp.core.wasm +0 -0
- package/dist/openapi2mcp.d.ts +18 -17
- package/dist/openapi2mcp.js +655 -359
- package/node_modules/@bytecodealliance/preview2-shim/LICENSE +220 -0
- package/node_modules/@bytecodealliance/preview2-shim/README.md +113 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/cli.js +135 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/clocks.js +39 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/config.js +9 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/environment.js +29 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/filesystem.js +485 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/http.js +707 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/index.js +9 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/io.js +262 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/random.js +56 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/browser/sockets.js +88 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/common/instantiation.js +253 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/calls.js +128 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-http.js +206 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-io.js +468 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-socket-tcp.js +331 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-socket-udp.js +587 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-sockets.js +364 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/io/worker-thread.js +1051 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/cli.js +109 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/clocks.js +67 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/filesystem.js +829 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/http.js +764 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/index.js +9 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/io.js +1 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/random.js +49 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/nodejs/sockets.js +565 -0
- package/node_modules/@bytecodealliance/preview2-shim/lib/synckit/index.js +127 -0
- package/node_modules/@bytecodealliance/preview2-shim/package.json +65 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/cli.d.ts +11 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/clocks.d.ts +2 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/filesystem.d.ts +29 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/http.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/index.d.ts +6 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/instantiation.d.ts +199 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-environment.d.ts +21 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-exit.d.ts +6 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-run.d.ts +5 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stderr.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stdin.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-stdout.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-input.d.ts +8 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-output.d.ts +8 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stderr.d.ts +7 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stdin.d.ts +7 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-cli-terminal-stdout.d.ts +7 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-clocks-monotonic-clock.d.ts +34 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-clocks-wall-clock.d.ts +30 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-filesystem-preopens.d.ts +6 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-filesystem-types.d.ts +669 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-incoming-handler.d.ts +16 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-outgoing-handler.d.ts +18 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-http-types.d.ts +748 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-error.d.ts +18 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-poll.d.ts +44 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-io-streams.d.ts +243 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure-seed.d.ts +21 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure.d.ts +19 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-random.d.ts +23 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-instance-network.d.ts +6 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-ip-name-lookup.d.ts +58 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-network.d.ts +164 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-tcp-create-socket.d.ts +28 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-tcp.d.ts +359 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-udp-create-socket.d.ts +28 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-udp.d.ts +301 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/io.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/random.d.ts +3 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/sockets.d.ts +7 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/wasi-cli-command.d.ts +29 -0
- package/node_modules/@bytecodealliance/preview2-shim/types/wasi-http-proxy.d.ts +13 -0
- package/package.json +9 -6
- package/patches/@bytecodealliance+preview2-shim+0.18.0.patch +13 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @module Interface wasi:io/error@0.2.3 **/
|
|
2
|
+
|
|
3
|
+
export class Error {
|
|
4
|
+
/**
|
|
5
|
+
* This type does not have a public constructor.
|
|
6
|
+
*/
|
|
7
|
+
private constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Returns a string that is suitable to assist humans in debugging
|
|
10
|
+
* this error.
|
|
11
|
+
*
|
|
12
|
+
* WARNING: The returned string should not be consumed mechanically!
|
|
13
|
+
* It may change across platforms, hosts, or other implementation
|
|
14
|
+
* details. Parsing this string is a major platform-compatibility
|
|
15
|
+
* hazard.
|
|
16
|
+
*/
|
|
17
|
+
toDebugString(): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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;
|
|
24
|
+
|
|
25
|
+
export class Pollable {
|
|
26
|
+
/**
|
|
27
|
+
* This type does not have a public constructor.
|
|
28
|
+
*/
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Return the readiness of a pollable. This function never blocks.
|
|
32
|
+
*
|
|
33
|
+
* Returns `true` when the pollable is ready, and `false` otherwise.
|
|
34
|
+
*/
|
|
35
|
+
ready(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* `block` returns immediately if the pollable is ready, and otherwise
|
|
38
|
+
* blocks until ready.
|
|
39
|
+
*
|
|
40
|
+
* This function is equivalent to calling `poll.poll` on a list
|
|
41
|
+
* containing only this pollable.
|
|
42
|
+
*/
|
|
43
|
+
block(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
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;
|
|
4
|
+
/**
|
|
5
|
+
* An error for input-stream and output-stream operations.
|
|
6
|
+
*/
|
|
7
|
+
export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
|
8
|
+
/**
|
|
9
|
+
* The last operation (a write or flush) failed before completion.
|
|
10
|
+
*
|
|
11
|
+
* More information is available in the `error` payload.
|
|
12
|
+
*
|
|
13
|
+
* After this, the stream will be closed. All future operations return
|
|
14
|
+
* `stream-error::closed`.
|
|
15
|
+
*/
|
|
16
|
+
export interface StreamErrorLastOperationFailed {
|
|
17
|
+
tag: 'last-operation-failed',
|
|
18
|
+
val: Error,
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The stream is closed: no more input will be accepted by the
|
|
22
|
+
* stream. A closed output-stream will return this error on all
|
|
23
|
+
* future operations.
|
|
24
|
+
*/
|
|
25
|
+
export interface StreamErrorClosed {
|
|
26
|
+
tag: 'closed',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class InputStream {
|
|
30
|
+
/**
|
|
31
|
+
* This type does not have a public constructor.
|
|
32
|
+
*/
|
|
33
|
+
private constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Perform a non-blocking read from the stream.
|
|
36
|
+
*
|
|
37
|
+
* When the source of a `read` is binary data, the bytes from the source
|
|
38
|
+
* are returned verbatim. When the source of a `read` is known to the
|
|
39
|
+
* implementation to be text, bytes containing the UTF-8 encoding of the
|
|
40
|
+
* text are returned.
|
|
41
|
+
*
|
|
42
|
+
* This function returns a list of bytes containing the read data,
|
|
43
|
+
* when successful. The returned list will contain up to `len` bytes;
|
|
44
|
+
* it may return fewer than requested, but not more. The list is
|
|
45
|
+
* empty when no bytes are available for reading at this time. The
|
|
46
|
+
* pollable given by `subscribe` will be ready when more bytes are
|
|
47
|
+
* available.
|
|
48
|
+
*
|
|
49
|
+
* This function fails with a `stream-error` when the operation
|
|
50
|
+
* encounters an error, giving `last-operation-failed`, or when the
|
|
51
|
+
* stream is closed, giving `closed`.
|
|
52
|
+
*
|
|
53
|
+
* When the caller gives a `len` of 0, it represents a request to
|
|
54
|
+
* read 0 bytes. If the stream is still open, this call should
|
|
55
|
+
* succeed and return an empty list, or otherwise fail with `closed`.
|
|
56
|
+
*
|
|
57
|
+
* The `len` parameter is a `u64`, which could represent a list of u8 which
|
|
58
|
+
* is not possible to allocate in wasm32, or not desirable to allocate as
|
|
59
|
+
* as a return value by the callee. The callee may return a list of bytes
|
|
60
|
+
* less than `len` in size while more bytes are available for reading.
|
|
61
|
+
*/
|
|
62
|
+
read(len: bigint): Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* Read bytes from a stream, after blocking until at least one byte can
|
|
65
|
+
* be read. Except for blocking, behavior is identical to `read`.
|
|
66
|
+
*/
|
|
67
|
+
blockingRead(len: bigint): Uint8Array;
|
|
68
|
+
/**
|
|
69
|
+
* Skip bytes from a stream. Returns number of bytes skipped.
|
|
70
|
+
*
|
|
71
|
+
* Behaves identical to `read`, except instead of returning a list
|
|
72
|
+
* of bytes, returns the number of bytes consumed from the stream.
|
|
73
|
+
*/
|
|
74
|
+
skip(len: bigint): bigint;
|
|
75
|
+
/**
|
|
76
|
+
* Skip bytes from a stream, after blocking until at least one byte
|
|
77
|
+
* can be skipped. Except for blocking behavior, identical to `skip`.
|
|
78
|
+
*/
|
|
79
|
+
blockingSkip(len: bigint): bigint;
|
|
80
|
+
/**
|
|
81
|
+
* Create a `pollable` which will resolve once either the specified stream
|
|
82
|
+
* has bytes available to read or the other end of the stream has been
|
|
83
|
+
* closed.
|
|
84
|
+
* The created `pollable` is a child resource of the `input-stream`.
|
|
85
|
+
* Implementations may trap if the `input-stream` is dropped before
|
|
86
|
+
* all derived `pollable`s created with this function are dropped.
|
|
87
|
+
*/
|
|
88
|
+
subscribe(): Pollable;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class OutputStream {
|
|
92
|
+
/**
|
|
93
|
+
* This type does not have a public constructor.
|
|
94
|
+
*/
|
|
95
|
+
private constructor();
|
|
96
|
+
/**
|
|
97
|
+
* Check readiness for writing. This function never blocks.
|
|
98
|
+
*
|
|
99
|
+
* Returns the number of bytes permitted for the next call to `write`,
|
|
100
|
+
* or an error. Calling `write` with more bytes than this function has
|
|
101
|
+
* permitted will trap.
|
|
102
|
+
*
|
|
103
|
+
* When this function returns 0 bytes, the `subscribe` pollable will
|
|
104
|
+
* become ready when this function will report at least 1 byte, or an
|
|
105
|
+
* error.
|
|
106
|
+
*/
|
|
107
|
+
checkWrite(): bigint;
|
|
108
|
+
/**
|
|
109
|
+
* Perform a write. This function never blocks.
|
|
110
|
+
*
|
|
111
|
+
* When the destination of a `write` is binary data, the bytes from
|
|
112
|
+
* `contents` are written verbatim. When the destination of a `write` is
|
|
113
|
+
* known to the implementation to be text, the bytes of `contents` are
|
|
114
|
+
* transcoded from UTF-8 into the encoding of the destination and then
|
|
115
|
+
* written.
|
|
116
|
+
*
|
|
117
|
+
* Precondition: check-write gave permit of Ok(n) and contents has a
|
|
118
|
+
* length of less than or equal to n. Otherwise, this function will trap.
|
|
119
|
+
*
|
|
120
|
+
* returns Err(closed) without writing if the stream has closed since
|
|
121
|
+
* the last call to check-write provided a permit.
|
|
122
|
+
*/
|
|
123
|
+
write(contents: Uint8Array): void;
|
|
124
|
+
/**
|
|
125
|
+
* Perform a write of up to 4096 bytes, and then flush the stream. Block
|
|
126
|
+
* until all of these operations are complete, or an error occurs.
|
|
127
|
+
*
|
|
128
|
+
* This is a convenience wrapper around the use of `check-write`,
|
|
129
|
+
* `subscribe`, `write`, and `flush`, and is implemented with the
|
|
130
|
+
* following pseudo-code:
|
|
131
|
+
*
|
|
132
|
+
* ```text
|
|
133
|
+
* let pollable = this.subscribe();
|
|
134
|
+
* while !contents.is_empty() {
|
|
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;
|
|
142
|
+
* }
|
|
143
|
+
* this.flush();
|
|
144
|
+
* // Wait for completion of `flush`
|
|
145
|
+
* pollable.block();
|
|
146
|
+
* // Check for any errors that arose during `flush`
|
|
147
|
+
* let _ = this.check-write(); // eliding error handling
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
blockingWriteAndFlush(contents: Uint8Array): void;
|
|
151
|
+
/**
|
|
152
|
+
* Request to flush buffered output. This function never blocks.
|
|
153
|
+
*
|
|
154
|
+
* This tells the output-stream that the caller intends any buffered
|
|
155
|
+
* output to be flushed. the output which is expected to be flushed
|
|
156
|
+
* is all that has been passed to `write` prior to this call.
|
|
157
|
+
*
|
|
158
|
+
* Upon calling this function, the `output-stream` will not accept any
|
|
159
|
+
* writes (`check-write` will return `ok(0)`) until the flush has
|
|
160
|
+
* completed. The `subscribe` pollable will become ready when the
|
|
161
|
+
* flush has completed and the stream can accept more writes.
|
|
162
|
+
*/
|
|
163
|
+
flush(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Request to flush buffered output, and block until flush completes
|
|
166
|
+
* and stream is ready for writing again.
|
|
167
|
+
*/
|
|
168
|
+
blockingFlush(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Create a `pollable` which will resolve once the output-stream
|
|
171
|
+
* is ready for more writing, or an error has occurred. When this
|
|
172
|
+
* pollable is ready, `check-write` will return `ok(n)` with n>0, or an
|
|
173
|
+
* error.
|
|
174
|
+
*
|
|
175
|
+
* If the stream is closed, this pollable is always ready immediately.
|
|
176
|
+
*
|
|
177
|
+
* The created `pollable` is a child resource of the `output-stream`.
|
|
178
|
+
* Implementations may trap if the `output-stream` is dropped before
|
|
179
|
+
* all derived `pollable`s created with this function are dropped.
|
|
180
|
+
*/
|
|
181
|
+
subscribe(): Pollable;
|
|
182
|
+
/**
|
|
183
|
+
* Write zeroes to a stream.
|
|
184
|
+
*
|
|
185
|
+
* This should be used precisely like `write` with the exact same
|
|
186
|
+
* preconditions (must use check-write first), but instead of
|
|
187
|
+
* passing a list of bytes, you simply pass the number of zero-bytes
|
|
188
|
+
* that should be written.
|
|
189
|
+
*/
|
|
190
|
+
writeZeroes(len: bigint): void;
|
|
191
|
+
/**
|
|
192
|
+
* Perform a write of up to 4096 zeroes, and then flush the stream.
|
|
193
|
+
* Block until all of these operations are complete, or an error
|
|
194
|
+
* occurs.
|
|
195
|
+
*
|
|
196
|
+
* This is a convenience wrapper around the use of `check-write`,
|
|
197
|
+
* `subscribe`, `write-zeroes`, and `flush`, and is implemented with
|
|
198
|
+
* the following pseudo-code:
|
|
199
|
+
*
|
|
200
|
+
* ```text
|
|
201
|
+
* let pollable = this.subscribe();
|
|
202
|
+
* while num_zeroes != 0 {
|
|
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;
|
|
209
|
+
* }
|
|
210
|
+
* this.flush();
|
|
211
|
+
* // Wait for completion of `flush`
|
|
212
|
+
* pollable.block();
|
|
213
|
+
* // Check for any errors that arose during `flush`
|
|
214
|
+
* let _ = this.check-write(); // eliding error handling
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
blockingWriteZeroesAndFlush(len: bigint): void;
|
|
218
|
+
/**
|
|
219
|
+
* Read from one stream and write to another.
|
|
220
|
+
*
|
|
221
|
+
* The behavior of splice is equivalent to:
|
|
222
|
+
* 1. calling `check-write` on the `output-stream`
|
|
223
|
+
* 2. calling `read` on the `input-stream` with the smaller of the
|
|
224
|
+
* `check-write` permitted length and the `len` provided to `splice`
|
|
225
|
+
* 3. calling `write` on the `output-stream` with that read data.
|
|
226
|
+
*
|
|
227
|
+
* Any error reported by the call to `check-write`, `read`, or
|
|
228
|
+
* `write` ends the splice and reports that error.
|
|
229
|
+
*
|
|
230
|
+
* This function returns the number of bytes transferred; it may be less
|
|
231
|
+
* than `len`.
|
|
232
|
+
*/
|
|
233
|
+
splice(src: InputStream, len: bigint): bigint;
|
|
234
|
+
/**
|
|
235
|
+
* Read from one stream and write to another, with blocking.
|
|
236
|
+
*
|
|
237
|
+
* This is similar to `splice`, except that it blocks until the
|
|
238
|
+
* `output-stream` is ready for writing, and the `input-stream`
|
|
239
|
+
* is ready for reading, before performing the `splice`.
|
|
240
|
+
*/
|
|
241
|
+
blockingSplice(src: InputStream, len: bigint): bigint;
|
|
242
|
+
}
|
|
243
|
+
|
package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure-seed.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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];
|
package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-random-insecure.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1,23 @@
|
|
|
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;
|
|
@@ -0,0 +1,58 @@
|
|
|
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;
|
|
29
|
+
|
|
30
|
+
export class ResolveAddressStream {
|
|
31
|
+
/**
|
|
32
|
+
* This type does not have a public constructor.
|
|
33
|
+
*/
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Returns the next address from the resolver.
|
|
37
|
+
*
|
|
38
|
+
* This function should be called multiple times. On each call, it will
|
|
39
|
+
* return the next address in connection order preference. If all
|
|
40
|
+
* addresses have been exhausted, this function returns `none`.
|
|
41
|
+
*
|
|
42
|
+
* This function never returns IPv4-mapped IPv6 addresses.
|
|
43
|
+
*
|
|
44
|
+
* # Typical errors
|
|
45
|
+
* - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
|
|
46
|
+
* - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
|
|
47
|
+
* - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
|
|
48
|
+
* - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
|
|
49
|
+
*/
|
|
50
|
+
resolveNextAddress(): IpAddress | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Create a `pollable` which will resolve once the stream is ready for I/O.
|
|
53
|
+
*
|
|
54
|
+
* Note: this function is here for WASI 0.2 only.
|
|
55
|
+
* It's planned to be removed when `future` is natively supported in Preview3.
|
|
56
|
+
*/
|
|
57
|
+
subscribe(): Pollable;
|
|
58
|
+
}
|
package/node_modules/@bytecodealliance/preview2-shim/types/interfaces/wasi-sockets-network.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/** @module Interface wasi:sockets/network@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Error codes.
|
|
4
|
+
*
|
|
5
|
+
* In theory, every API can return any error code.
|
|
6
|
+
* In practice, API's typically only return the errors documented per API
|
|
7
|
+
* combined with a couple of errors that are always possible:
|
|
8
|
+
* - `unknown`
|
|
9
|
+
* - `access-denied`
|
|
10
|
+
* - `not-supported`
|
|
11
|
+
* - `out-of-memory`
|
|
12
|
+
* - `concurrency-conflict`
|
|
13
|
+
*
|
|
14
|
+
* See each individual API for what the POSIX equivalents are. They sometimes differ per API.
|
|
15
|
+
* # Variants
|
|
16
|
+
*
|
|
17
|
+
* ## `"unknown"`
|
|
18
|
+
*
|
|
19
|
+
* Unknown error
|
|
20
|
+
* ## `"access-denied"`
|
|
21
|
+
*
|
|
22
|
+
* Access denied.
|
|
23
|
+
*
|
|
24
|
+
* POSIX equivalent: EACCES, EPERM
|
|
25
|
+
* ## `"not-supported"`
|
|
26
|
+
*
|
|
27
|
+
* The operation is not supported.
|
|
28
|
+
*
|
|
29
|
+
* POSIX equivalent: EOPNOTSUPP
|
|
30
|
+
* ## `"invalid-argument"`
|
|
31
|
+
*
|
|
32
|
+
* One of the arguments is invalid.
|
|
33
|
+
*
|
|
34
|
+
* POSIX equivalent: EINVAL
|
|
35
|
+
* ## `"out-of-memory"`
|
|
36
|
+
*
|
|
37
|
+
* Not enough memory to complete the operation.
|
|
38
|
+
*
|
|
39
|
+
* POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
|
|
40
|
+
* ## `"timeout"`
|
|
41
|
+
*
|
|
42
|
+
* The operation timed out before it could finish completely.
|
|
43
|
+
* ## `"concurrency-conflict"`
|
|
44
|
+
*
|
|
45
|
+
* This operation is incompatible with another asynchronous operation that is already in progress.
|
|
46
|
+
*
|
|
47
|
+
* POSIX equivalent: EALREADY
|
|
48
|
+
* ## `"not-in-progress"`
|
|
49
|
+
*
|
|
50
|
+
* Trying to finish an asynchronous operation that:
|
|
51
|
+
* - has not been started yet, or:
|
|
52
|
+
* - was already finished by a previous `finish-*` call.
|
|
53
|
+
*
|
|
54
|
+
* Note: this is scheduled to be removed when `future`s are natively supported.
|
|
55
|
+
* ## `"would-block"`
|
|
56
|
+
*
|
|
57
|
+
* The operation has been aborted because it could not be completed immediately.
|
|
58
|
+
*
|
|
59
|
+
* Note: this is scheduled to be removed when `future`s are natively supported.
|
|
60
|
+
* ## `"invalid-state"`
|
|
61
|
+
*
|
|
62
|
+
* The operation is not valid in the socket's current state.
|
|
63
|
+
* ## `"new-socket-limit"`
|
|
64
|
+
*
|
|
65
|
+
* A new socket resource could not be created because of a system limit.
|
|
66
|
+
* ## `"address-not-bindable"`
|
|
67
|
+
*
|
|
68
|
+
* A bind operation failed because the provided address is not an address that the `network` can bind to.
|
|
69
|
+
* ## `"address-in-use"`
|
|
70
|
+
*
|
|
71
|
+
* A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
|
|
72
|
+
* ## `"remote-unreachable"`
|
|
73
|
+
*
|
|
74
|
+
* The remote address is not reachable
|
|
75
|
+
* ## `"connection-refused"`
|
|
76
|
+
*
|
|
77
|
+
* The TCP connection was forcefully rejected
|
|
78
|
+
* ## `"connection-reset"`
|
|
79
|
+
*
|
|
80
|
+
* The TCP connection was reset.
|
|
81
|
+
* ## `"connection-aborted"`
|
|
82
|
+
*
|
|
83
|
+
* A TCP connection was aborted.
|
|
84
|
+
* ## `"datagram-too-large"`
|
|
85
|
+
*
|
|
86
|
+
* The size of a datagram sent to a UDP socket exceeded the maximum
|
|
87
|
+
* supported size.
|
|
88
|
+
* ## `"name-unresolvable"`
|
|
89
|
+
*
|
|
90
|
+
* Name does not exist or has no suitable associated IP addresses.
|
|
91
|
+
* ## `"temporary-resolver-failure"`
|
|
92
|
+
*
|
|
93
|
+
* A temporary failure in name resolution occurred.
|
|
94
|
+
* ## `"permanent-resolver-failure"`
|
|
95
|
+
*
|
|
96
|
+
* A permanent failure in name resolution occurred.
|
|
97
|
+
*/
|
|
98
|
+
export type ErrorCode = 'unknown' | 'access-denied' | 'not-supported' | 'invalid-argument' | 'out-of-memory' | 'timeout' | 'concurrency-conflict' | 'not-in-progress' | 'would-block' | 'invalid-state' | 'new-socket-limit' | 'address-not-bindable' | 'address-in-use' | 'remote-unreachable' | 'connection-refused' | 'connection-reset' | 'connection-aborted' | 'datagram-too-large' | 'name-unresolvable' | 'temporary-resolver-failure' | 'permanent-resolver-failure';
|
|
99
|
+
/**
|
|
100
|
+
* # Variants
|
|
101
|
+
*
|
|
102
|
+
* ## `"ipv4"`
|
|
103
|
+
*
|
|
104
|
+
* Similar to `AF_INET` in POSIX.
|
|
105
|
+
* ## `"ipv6"`
|
|
106
|
+
*
|
|
107
|
+
* Similar to `AF_INET6` in POSIX.
|
|
108
|
+
*/
|
|
109
|
+
export type IpAddressFamily = 'ipv4' | 'ipv6';
|
|
110
|
+
export type Ipv4Address = [number, number, number, number];
|
|
111
|
+
export type Ipv6Address = [number, number, number, number, number, number, number, number];
|
|
112
|
+
export type IpAddress = IpAddressIpv4 | IpAddressIpv6;
|
|
113
|
+
export interface IpAddressIpv4 {
|
|
114
|
+
tag: 'ipv4',
|
|
115
|
+
val: Ipv4Address,
|
|
116
|
+
}
|
|
117
|
+
export interface IpAddressIpv6 {
|
|
118
|
+
tag: 'ipv6',
|
|
119
|
+
val: Ipv6Address,
|
|
120
|
+
}
|
|
121
|
+
export interface Ipv4SocketAddress {
|
|
122
|
+
/**
|
|
123
|
+
* sin_port
|
|
124
|
+
*/
|
|
125
|
+
port: number,
|
|
126
|
+
/**
|
|
127
|
+
* sin_addr
|
|
128
|
+
*/
|
|
129
|
+
address: Ipv4Address,
|
|
130
|
+
}
|
|
131
|
+
export interface Ipv6SocketAddress {
|
|
132
|
+
/**
|
|
133
|
+
* sin6_port
|
|
134
|
+
*/
|
|
135
|
+
port: number,
|
|
136
|
+
/**
|
|
137
|
+
* sin6_flowinfo
|
|
138
|
+
*/
|
|
139
|
+
flowInfo: number,
|
|
140
|
+
/**
|
|
141
|
+
* sin6_addr
|
|
142
|
+
*/
|
|
143
|
+
address: Ipv6Address,
|
|
144
|
+
/**
|
|
145
|
+
* sin6_scope_id
|
|
146
|
+
*/
|
|
147
|
+
scopeId: number,
|
|
148
|
+
}
|
|
149
|
+
export type IpSocketAddress = IpSocketAddressIpv4 | IpSocketAddressIpv6;
|
|
150
|
+
export interface IpSocketAddressIpv4 {
|
|
151
|
+
tag: 'ipv4',
|
|
152
|
+
val: Ipv4SocketAddress,
|
|
153
|
+
}
|
|
154
|
+
export interface IpSocketAddressIpv6 {
|
|
155
|
+
tag: 'ipv6',
|
|
156
|
+
val: Ipv6SocketAddress,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export class Network {
|
|
160
|
+
/**
|
|
161
|
+
* This type does not have a public constructor.
|
|
162
|
+
*/
|
|
163
|
+
private constructor();
|
|
164
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @module Interface wasi:sockets/tcp-create-socket@0.2.3 **/
|
|
2
|
+
/**
|
|
3
|
+
* Create a new TCP socket.
|
|
4
|
+
*
|
|
5
|
+
* Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
|
|
6
|
+
* On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
|
|
7
|
+
*
|
|
8
|
+
* This function does not require a network capability handle. This is considered to be safe because
|
|
9
|
+
* at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect`
|
|
10
|
+
* is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world.
|
|
11
|
+
*
|
|
12
|
+
* All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations.
|
|
13
|
+
*
|
|
14
|
+
* # Typical errors
|
|
15
|
+
* - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT)
|
|
16
|
+
* - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
|
|
17
|
+
*
|
|
18
|
+
* # References
|
|
19
|
+
* - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
|
|
20
|
+
* - <https://man7.org/linux/man-pages/man2/socket.2.html>
|
|
21
|
+
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
|
|
22
|
+
* - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
|
|
23
|
+
*/
|
|
24
|
+
export function createTcpSocket(addressFamily: IpAddressFamily): TcpSocket;
|
|
25
|
+
export type Network = import('./wasi-sockets-network.js').Network;
|
|
26
|
+
export type ErrorCode = import('./wasi-sockets-network.js').ErrorCode;
|
|
27
|
+
export type IpAddressFamily = import('./wasi-sockets-network.js').IpAddressFamily;
|
|
28
|
+
export type TcpSocket = import('./wasi-sockets-tcp.js').TcpSocket;
|