@terminal3/t3n-sdk 0.2.1

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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.OIDC.md +216 -0
  3. package/README.md +639 -0
  4. package/dist/demo.d.ts +25 -0
  5. package/dist/index.d.ts +819 -0
  6. package/dist/index.esm.js +2 -0
  7. package/dist/index.js +2 -0
  8. package/dist/src/client/actions.d.ts +17 -0
  9. package/dist/src/client/config.d.ts +35 -0
  10. package/dist/src/client/encryption.d.ts +30 -0
  11. package/dist/src/client/handlers.d.ts +45 -0
  12. package/dist/src/client/index.d.ts +10 -0
  13. package/dist/src/client/request-parser.d.ts +48 -0
  14. package/dist/src/client/t3n-client.d.ts +70 -0
  15. package/dist/src/client/transport.d.ts +107 -0
  16. package/dist/src/config/index.d.ts +67 -0
  17. package/dist/src/config/loader.d.ts +11 -0
  18. package/dist/src/config/types.d.ts +25 -0
  19. package/dist/src/index.d.ts +23 -0
  20. package/dist/src/types/auth.d.ts +54 -0
  21. package/dist/src/types/index.d.ts +35 -0
  22. package/dist/src/types/session.d.ts +24 -0
  23. package/dist/src/utils/contract-version.d.ts +5 -0
  24. package/dist/src/utils/crypto.d.ts +52 -0
  25. package/dist/src/utils/errors.d.ts +61 -0
  26. package/dist/src/utils/index.d.ts +9 -0
  27. package/dist/src/utils/logger.d.ts +102 -0
  28. package/dist/src/utils/redaction.d.ts +13 -0
  29. package/dist/src/utils/session.d.ts +37 -0
  30. package/dist/src/wasm/index.d.ts +5 -0
  31. package/dist/src/wasm/interface.d.ts +105 -0
  32. package/dist/src/wasm/loader.d.ts +43 -0
  33. package/dist/wasm/generated/interfaces/component-session-client-auth.d.ts +12 -0
  34. package/dist/wasm/generated/interfaces/component-session-client-handshake.d.ts +12 -0
  35. package/dist/wasm/generated/interfaces/component-session-server-auth.d.ts +12 -0
  36. package/dist/wasm/generated/interfaces/component-session-server-handshake.d.ts +12 -0
  37. package/dist/wasm/generated/interfaces/component-session-session.d.ts +8 -0
  38. package/dist/wasm/generated/interfaces/wasi-cli-environment.d.ts +2 -0
  39. package/dist/wasm/generated/interfaces/wasi-cli-exit.d.ts +3 -0
  40. package/dist/wasm/generated/interfaces/wasi-cli-stderr.d.ts +3 -0
  41. package/dist/wasm/generated/interfaces/wasi-cli-stdin.d.ts +3 -0
  42. package/dist/wasm/generated/interfaces/wasi-cli-stdout.d.ts +3 -0
  43. package/dist/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts +5 -0
  44. package/dist/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts +3 -0
  45. package/dist/wasm/generated/interfaces/wasi-filesystem-types.d.ts +124 -0
  46. package/dist/wasm/generated/interfaces/wasi-io-error.d.ts +8 -0
  47. package/dist/wasm/generated/interfaces/wasi-io-streams.d.ts +28 -0
  48. package/dist/wasm/generated/session.core.wasm +0 -0
  49. package/dist/wasm/generated/session.core2.wasm +0 -0
  50. package/dist/wasm/generated/session.d.ts +16 -0
  51. package/dist/wasm/generated/session.js +3437 -0
  52. package/package.json +104 -0
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Error classes for T3n SDK
3
+ */
4
+ /**
5
+ * Base error class for T3n SDK errors
6
+ */
7
+ export declare class T3nError extends Error {
8
+ readonly code?: string | undefined;
9
+ constructor(message: string, code?: string | undefined);
10
+ }
11
+ /**
12
+ * Error thrown when session is in invalid state for operation
13
+ */
14
+ export declare class SessionStateError extends T3nError {
15
+ readonly currentState: string;
16
+ constructor(message: string, currentState: string);
17
+ }
18
+ /**
19
+ * Error thrown during authentication process
20
+ */
21
+ export declare class AuthenticationError extends T3nError {
22
+ readonly authMethod?: string | undefined;
23
+ constructor(message: string, authMethod?: string | undefined);
24
+ }
25
+ /**
26
+ * Error thrown during handshake process
27
+ */
28
+ export declare class HandshakeError extends T3nError {
29
+ constructor(message: string);
30
+ }
31
+ /**
32
+ * Error thrown during RPC communication
33
+ */
34
+ export declare class RpcError extends T3nError {
35
+ readonly rpcMethod?: string | undefined;
36
+ readonly httpStatus?: number | undefined;
37
+ constructor(message: string, rpcMethod?: string | undefined, httpStatus?: number | undefined);
38
+ }
39
+ /**
40
+ * Error thrown when WASM operations fail
41
+ */
42
+ export declare class WasmError extends T3nError {
43
+ readonly operation?: string | undefined;
44
+ readonly payload?: unknown | undefined;
45
+ constructor(message: string, operation?: string | undefined, payload?: unknown | undefined);
46
+ }
47
+ /**
48
+ * Decode WASM error message from comma-separated byte array format
49
+ * WASM errors often come as "83,101,114,100,101..." which represents ASCII bytes
50
+ *
51
+ * @param errorMessage - The error message string that may contain comma-separated bytes
52
+ * @returns Decoded error message if it was encoded, otherwise original message
53
+ */
54
+ export declare function decodeWasmErrorMessage(errorMessage: string): string;
55
+ /**
56
+ * Extract and decode error from WASM ComponentError
57
+ *
58
+ * @param error - The error object from WASM
59
+ * @returns Decoded error message
60
+ */
61
+ export declare function extractWasmError(error: unknown): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utility exports for T3n SDK
3
+ */
4
+ export * from "./crypto";
5
+ export * from "./contract-version";
6
+ export * from "./errors";
7
+ export * from "./logger";
8
+ export * from "./redaction";
9
+ export * from "./session";
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Logger interface and implementations for T3n SDK
3
+ *
4
+ * Provides hierarchical log level control (DEBUG, INFO, WARN, ERROR) with
5
+ * global defaults and per-component override capabilities.
6
+ *
7
+ * ## Usage
8
+ *
9
+ * ```typescript
10
+ * import { getLogger, setGlobalLogLevel, LogLevel } from '@t3n-sdk/logger';
11
+ *
12
+ * // Use the global logger (defaults to ERROR level)
13
+ * const logger = getLogger();
14
+ * logger.error("This will be logged");
15
+ * logger.debug("This will NOT be logged by default");
16
+ *
17
+ * // Enable debug logging globally
18
+ * setGlobalLogLevel(LogLevel.DEBUG);
19
+ * const debugLogger = getLogger();
20
+ * debugLogger.debug("This will now be logged");
21
+ *
22
+ * // Create a logger with a specific level (overrides global)
23
+ * const infoLogger = createLogger(LogLevel.INFO);
24
+ * infoLogger.info("This will be logged");
25
+ * infoLogger.debug("This will NOT be logged");
26
+ * ```
27
+ *
28
+ * ## Log Levels
29
+ *
30
+ * - `DEBUG` (0): Most verbose, logs everything
31
+ * - `INFO` (1): Logs info, warnings, and errors
32
+ * - `WARN` (2): Logs warnings and errors only
33
+ * - `ERROR` (3): Logs errors only (default)
34
+ */
35
+ /**
36
+ * Log levels in hierarchical order (lower values = more verbose)
37
+ */
38
+ export declare enum LogLevel {
39
+ DEBUG = 0,
40
+ INFO = 1,
41
+ WARN = 2,
42
+ ERROR = 3
43
+ }
44
+ /**
45
+ * Logger interface for SDK debugging and monitoring
46
+ */
47
+ export interface Logger {
48
+ /**
49
+ * Log a debug message (most verbose)
50
+ * @param args - Arguments to log
51
+ */
52
+ debug(...args: any[]): void;
53
+ /**
54
+ * Log an info message
55
+ * @param args - Arguments to log
56
+ */
57
+ info(...args: any[]): void;
58
+ /**
59
+ * Log a warning message
60
+ * @param args - Arguments to log
61
+ */
62
+ warn(...args: any[]): void;
63
+ /**
64
+ * Log an error message (least verbose)
65
+ * @param args - Arguments to log
66
+ */
67
+ error(...args: any[]): void;
68
+ }
69
+ /**
70
+ * Set the global default log level for all components
71
+ *
72
+ * This affects all loggers created without an explicit log level.
73
+ * The default global log level is LogLevel.ERROR (only errors are logged).
74
+ *
75
+ * @param level - The log level to set as default for all components
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Enable debug logging globally
80
+ * setGlobalLogLevel(LogLevel.DEBUG);
81
+ *
82
+ * // Only log errors (default)
83
+ * setGlobalLogLevel(LogLevel.ERROR);
84
+ * ```
85
+ */
86
+ export declare function setGlobalLogLevel(level: LogLevel): void;
87
+ /**
88
+ * Get the current global log level
89
+ * @returns The current global log level (default: LogLevel.ERROR)
90
+ */
91
+ export declare function getGlobalLogLevel(): LogLevel;
92
+ /**
93
+ * Create a logger instance with the specified log level
94
+ * @param level - The log level for this logger. If not provided, defaults to the global log level (LogLevel.ERROR).
95
+ * @returns Logger instance configured with the specified or default log level
96
+ */
97
+ export declare function createLogger(level?: LogLevel): Logger;
98
+ /**
99
+ * Get a logger instance using the global log level
100
+ * @returns Logger instance with global log level (default: LogLevel.ERROR)
101
+ */
102
+ export declare function getLogger(): Logger;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Secret redaction utilities for T3n SDK
3
+ *
4
+ * Provides functions to redact sensitive information before logging
5
+ */
6
+ /**
7
+ * Redact secrets from values before logging
8
+ */
9
+ export declare function redactSecrets(value: any): any;
10
+ /**
11
+ * Redact secrets from a JSON string
12
+ */
13
+ export declare function redactSecretsFromJson(jsonString: string): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Session validation utilities for T3n SDK
3
+ */
4
+ import { Logger } from "./logger";
5
+ /**
6
+ * Validation result for session bytes
7
+ */
8
+ export interface SessionValidationResult {
9
+ /** Whether the session bytes are valid JSON */
10
+ isValidJSON: boolean;
11
+ /** Whether the parsed result is a string */
12
+ isString: boolean;
13
+ /** Whether the parsed result is a DID string */
14
+ isDID: boolean;
15
+ /** Whether the parsed result is an object with a 'secret' property */
16
+ hasSecret: boolean;
17
+ /** Type of the 'secret' property if it exists */
18
+ secretType?: string;
19
+ /** Whether the 'secret' is an array */
20
+ secretIsArray?: boolean;
21
+ /** Length of the 'secret' array if it's an array */
22
+ secretLength?: number | string;
23
+ /** Preview of the session text (first 100 chars) */
24
+ sessionPreview?: string;
25
+ /** Any error that occurred during validation */
26
+ error?: string;
27
+ }
28
+ /**
29
+ * Validate and analyze session bytes format
30
+ * Handles both JSON objects and DID strings safely
31
+ *
32
+ * @param sessionBytes - The session bytes to validate
33
+ * @param logger - Logger instance for debug/error output
34
+ * @param context - Optional context for logging
35
+ * @returns Validation result object
36
+ */
37
+ export declare function validateSessionBytes(sessionBytes: Uint8Array, logger: Logger, context?: string): SessionValidationResult;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * WASM integration exports for T3n SDK
3
+ */
4
+ export * from "./interface";
5
+ export * from "./loader";
@@ -0,0 +1,105 @@
1
+ /**
2
+ * WASM Component Interface - Mirrors the WIT specification exactly
3
+ *
4
+ * This interface works with completely opaque byte arrays, just like the WIT interface.
5
+ * The TypeScript SDK doesn't know about internal state machine phases or details.
6
+ */
7
+ /**
8
+ * Result type for WASM next() operations
9
+ */
10
+ export interface WasmNextResult {
11
+ state: Uint8Array;
12
+ request: Uint8Array;
13
+ }
14
+ /**
15
+ * Client handshake operations - completely opaque byte arrays only
16
+ */
17
+ export interface ClientHandshake {
18
+ /**
19
+ * Process next step in handshake
20
+ * @param state - Current handshake state (null for initial call)
21
+ * @param action - Action to process (opaque bytes)
22
+ * @returns Promise with new state and request to send
23
+ */
24
+ next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
25
+ /**
26
+ * Attempt to finalize handshake
27
+ * @param state - Current handshake state
28
+ * @returns Promise with session bytes if successful
29
+ * @throws Error if handshake not ready to finalize
30
+ */
31
+ finish(state: Uint8Array): Promise<Uint8Array>;
32
+ }
33
+ /**
34
+ * Client authentication operations - completely opaque byte arrays only
35
+ */
36
+ export interface ClientAuth {
37
+ /**
38
+ * Process next step in authentication
39
+ * @param state - Current auth state (null for initial call)
40
+ * @param action - Action to process (opaque bytes)
41
+ * @returns Promise with new state and request to send
42
+ */
43
+ next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
44
+ /**
45
+ * Attempt to finalize authentication
46
+ * @param state - Current auth state
47
+ * @returns Promise with DID bytes if successful
48
+ * @throws Error if authentication not ready to finalize
49
+ */
50
+ finish(state: Uint8Array): Promise<Uint8Array>;
51
+ }
52
+ /**
53
+ * Client authentication operations - completely opaque byte arrays only
54
+ */
55
+ export interface ClientExecute {
56
+ /**
57
+ * Process next step in authentication
58
+ * @param state - Current auth state (null for initial call)
59
+ * @param action - Action to process (opaque bytes)
60
+ * @returns Promise with new state and request to send
61
+ */
62
+ next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
63
+ /**
64
+ * Attempt to finalize authentication
65
+ * @param state - Current auth state
66
+ * @returns Promise with DID bytes if successful
67
+ * @throws Error if authentication not ready to finalize
68
+ */
69
+ finish(state: Uint8Array): Promise<Uint8Array>;
70
+ }
71
+ /**
72
+ * Session encryption/decryption operations - completely opaque byte arrays only
73
+ */
74
+ export interface SessionCrypto {
75
+ /**
76
+ * Encrypt plaintext using session
77
+ * @param session - Session state (opaque bytes)
78
+ * @param nonce - Nonce to use for encryption
79
+ * @param plaintext - Data to encrypt
80
+ * @returns Promise with encrypted bytes
81
+ */
82
+ encrypt(session: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
83
+ /**
84
+ * Decrypt ciphertext using session
85
+ * @param session - Session state (opaque bytes)
86
+ * @param ciphertext - Data to decrypt
87
+ * @returns Promise with decrypted bytes
88
+ */
89
+ decrypt(session: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
90
+ }
91
+ /**
92
+ * Main WASM Component interface - mirrors the WIT interface exactly
93
+ *
94
+ * This is completely opaque to the TypeScript layer. All state machine logic,
95
+ * authentication flows, and cryptographic operations are handled in WASM.
96
+ */
97
+ export interface WasmComponent {
98
+ /** Client handshake operations */
99
+ flow: {
100
+ handshake: ClientHandshake;
101
+ auth: ClientAuth;
102
+ execute: ClientExecute;
103
+ };
104
+ session: SessionCrypto;
105
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WASM Component Loader
3
+ *
4
+ * This module provides utilities for loading and initializing the WASM component.
5
+ * The actual WASM loading implementation will depend on the build system and
6
+ * deployment environment.
7
+ */
8
+ import { WasmComponent } from "./interface";
9
+ import { Logger } from "../utils/logger";
10
+ /**
11
+ * Configuration for WASM component loading
12
+ */
13
+ export interface WasmLoadConfig {
14
+ /** Path or URL to the WASM module */
15
+ wasmPath?: string;
16
+ /** Custom fetch function for loading WASM */
17
+ fetchFn?: typeof fetch;
18
+ /** Additional initialization options */
19
+ initOptions?: Record<string, any>;
20
+ /** Optional logger instance - if not provided, uses global default */
21
+ logger?: Logger;
22
+ }
23
+ /**
24
+ * Load and initialize the T3n WASM component
25
+ *
26
+ * @param config - Optional configuration for loading the WASM component
27
+ * @returns Promise that resolves to the initialized WASM component
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const wasmComponent = await loadWasmComponent({
32
+ * wasmPath: '/path/to/t3n.wasm'
33
+ * });
34
+ * ```
35
+ */
36
+ export declare function loadWasmComponent(config?: WasmLoadConfig): Promise<WasmComponent>;
37
+ /**
38
+ * Load the real T3n WASM component
39
+ *
40
+ * @param logger - Logger instance for WASM operations
41
+ * @returns Promise that resolves to the initialized WASM component
42
+ */
43
+ export declare function loadRealWasmComponent(logger: Logger): Promise<WasmComponent>;
@@ -0,0 +1,12 @@
1
+ /** @module Interface component:session/client-auth@0.1.0 **/
2
+ export function next(state: State | undefined, action: HostToGuest): NewState;
3
+ export function finish(state: State): Did;
4
+ export type GuestToHost = Uint8Array;
5
+ export type State = Uint8Array;
6
+ export type HostToGuest = Uint8Array;
7
+ export type Did = Uint8Array;
8
+ export type Error = Uint8Array;
9
+ export interface NewState {
10
+ state: State,
11
+ request: GuestToHost,
12
+ }
@@ -0,0 +1,12 @@
1
+ /** @module Interface component:session/client-handshake@0.1.0 **/
2
+ export function next(state: State | undefined, action: HostToGuest): NewState;
3
+ export function finish(state: State): SessionState;
4
+ export type GuestToHost = Uint8Array;
5
+ export type State = Uint8Array;
6
+ export type HostToGuest = Uint8Array;
7
+ export type SessionState = Uint8Array;
8
+ export type Error = Uint8Array;
9
+ export interface NewState {
10
+ state: State,
11
+ request: GuestToHost,
12
+ }
@@ -0,0 +1,12 @@
1
+ /** @module Interface component:session/server-auth@0.1.0 **/
2
+ export function next(state: State | undefined, action: HostToGuest): NewState;
3
+ export function finish(state: State): Did;
4
+ export type GuestToHost = Uint8Array;
5
+ export type State = Uint8Array;
6
+ export type HostToGuest = Uint8Array;
7
+ export type Did = Uint8Array;
8
+ export type Error = Uint8Array;
9
+ export interface NewState {
10
+ state: State,
11
+ request: GuestToHost,
12
+ }
@@ -0,0 +1,12 @@
1
+ /** @module Interface component:session/server-handshake@0.1.0 **/
2
+ export function next(state: State | undefined, action: HostToGuest): NewState;
3
+ export function finish(state: State): SessionState;
4
+ export type GuestToHost = Uint8Array;
5
+ export type State = Uint8Array;
6
+ export type HostToGuest = Uint8Array;
7
+ export type SessionState = Uint8Array;
8
+ export type Error = Uint8Array;
9
+ export interface NewState {
10
+ state: State,
11
+ request: GuestToHost,
12
+ }
@@ -0,0 +1,8 @@
1
+ /** @module Interface component:session/session@0.1.0 **/
2
+ export function encrypt(session: Session, nonce: Nonce, plaintext: Plaintext): Ciphertext;
3
+ export function decrypt(session: Session, ciphertext: Ciphertext): Plaintext;
4
+ export type Error = Uint8Array;
5
+ export type Session = Uint8Array;
6
+ export type Plaintext = Uint8Array;
7
+ export type Ciphertext = Uint8Array;
8
+ export type Nonce = Uint8Array;
@@ -0,0 +1,2 @@
1
+ /** @module Interface wasi:cli/environment@0.2.4 **/
2
+ export function getEnvironment(): Array<[string, string]>;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/exit@0.2.4 **/
2
+ export function exit(status: Result<void, void>): void;
3
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stderr@0.2.4 **/
2
+ export function getStderr(): OutputStream;
3
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stdin@0.2.4 **/
2
+ export function getStdin(): InputStream;
3
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stdout@0.2.4 **/
2
+ export function getStdout(): OutputStream;
3
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
@@ -0,0 +1,5 @@
1
+ /** @module Interface wasi:clocks/wall-clock@0.2.4 **/
2
+ export interface Datetime {
3
+ seconds: bigint,
4
+ nanoseconds: number,
5
+ }
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:filesystem/preopens@0.2.4 **/
2
+ export function getDirectories(): Array<[Descriptor, string]>;
3
+ export type Descriptor = import('./wasi-filesystem-types.js').Descriptor;
@@ -0,0 +1,124 @@
1
+ /** @module Interface wasi:filesystem/types@0.2.4 **/
2
+ export function filesystemErrorCode(err: Error): ErrorCode | undefined;
3
+ export type Error = import('./wasi-io-streams.js').Error;
4
+ /**
5
+ * # Variants
6
+ *
7
+ * ## `"access"`
8
+ *
9
+ * ## `"would-block"`
10
+ *
11
+ * ## `"already"`
12
+ *
13
+ * ## `"bad-descriptor"`
14
+ *
15
+ * ## `"busy"`
16
+ *
17
+ * ## `"deadlock"`
18
+ *
19
+ * ## `"quota"`
20
+ *
21
+ * ## `"exist"`
22
+ *
23
+ * ## `"file-too-large"`
24
+ *
25
+ * ## `"illegal-byte-sequence"`
26
+ *
27
+ * ## `"in-progress"`
28
+ *
29
+ * ## `"interrupted"`
30
+ *
31
+ * ## `"invalid"`
32
+ *
33
+ * ## `"io"`
34
+ *
35
+ * ## `"is-directory"`
36
+ *
37
+ * ## `"loop"`
38
+ *
39
+ * ## `"too-many-links"`
40
+ *
41
+ * ## `"message-size"`
42
+ *
43
+ * ## `"name-too-long"`
44
+ *
45
+ * ## `"no-device"`
46
+ *
47
+ * ## `"no-entry"`
48
+ *
49
+ * ## `"no-lock"`
50
+ *
51
+ * ## `"insufficient-memory"`
52
+ *
53
+ * ## `"insufficient-space"`
54
+ *
55
+ * ## `"not-directory"`
56
+ *
57
+ * ## `"not-empty"`
58
+ *
59
+ * ## `"not-recoverable"`
60
+ *
61
+ * ## `"unsupported"`
62
+ *
63
+ * ## `"no-tty"`
64
+ *
65
+ * ## `"no-such-device"`
66
+ *
67
+ * ## `"overflow"`
68
+ *
69
+ * ## `"not-permitted"`
70
+ *
71
+ * ## `"pipe"`
72
+ *
73
+ * ## `"read-only"`
74
+ *
75
+ * ## `"invalid-seek"`
76
+ *
77
+ * ## `"text-file-busy"`
78
+ *
79
+ * ## `"cross-device"`
80
+ */
81
+ export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
82
+ export type Filesize = bigint;
83
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
84
+ /**
85
+ * # Variants
86
+ *
87
+ * ## `"unknown"`
88
+ *
89
+ * ## `"block-device"`
90
+ *
91
+ * ## `"character-device"`
92
+ *
93
+ * ## `"directory"`
94
+ *
95
+ * ## `"fifo"`
96
+ *
97
+ * ## `"symbolic-link"`
98
+ *
99
+ * ## `"regular-file"`
100
+ *
101
+ * ## `"socket"`
102
+ */
103
+ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
104
+ export type LinkCount = bigint;
105
+ export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
106
+ export interface DescriptorStat {
107
+ type: DescriptorType,
108
+ linkCount: LinkCount,
109
+ size: Filesize,
110
+ dataAccessTimestamp?: Datetime,
111
+ dataModificationTimestamp?: Datetime,
112
+ statusChangeTimestamp?: Datetime,
113
+ }
114
+
115
+ export class Descriptor {
116
+ /**
117
+ * This type does not have a public constructor.
118
+ */
119
+ private constructor();
120
+ writeViaStream(offset: Filesize): OutputStream;
121
+ appendViaStream(): OutputStream;
122
+ getType(): DescriptorType;
123
+ stat(): DescriptorStat;
124
+ }
@@ -0,0 +1,8 @@
1
+ /** @module Interface wasi:io/error@0.2.4 **/
2
+
3
+ export class Error {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
8
+ }
@@ -0,0 +1,28 @@
1
+ /** @module Interface wasi:io/streams@0.2.4 **/
2
+ export type Error = import('./wasi-io-error.js').Error;
3
+ export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
4
+ export interface StreamErrorLastOperationFailed {
5
+ tag: 'last-operation-failed',
6
+ val: Error,
7
+ }
8
+ export interface StreamErrorClosed {
9
+ tag: 'closed',
10
+ }
11
+
12
+ export class InputStream {
13
+ /**
14
+ * This type does not have a public constructor.
15
+ */
16
+ private constructor();
17
+ }
18
+
19
+ export class OutputStream {
20
+ /**
21
+ * This type does not have a public constructor.
22
+ */
23
+ private constructor();
24
+ checkWrite(): bigint;
25
+ write(contents: Uint8Array): void;
26
+ blockingWriteAndFlush(contents: Uint8Array): void;
27
+ blockingFlush(): void;
28
+ }
@@ -0,0 +1,16 @@
1
+ // world root:component/root
2
+ export type * as WasiCliEnvironment024 from './interfaces/wasi-cli-environment.js'; // import wasi:cli/environment@0.2.4
3
+ export type * as WasiCliExit024 from './interfaces/wasi-cli-exit.js'; // import wasi:cli/exit@0.2.4
4
+ export type * as WasiCliStderr024 from './interfaces/wasi-cli-stderr.js'; // import wasi:cli/stderr@0.2.4
5
+ export type * as WasiCliStdin024 from './interfaces/wasi-cli-stdin.js'; // import wasi:cli/stdin@0.2.4
6
+ export type * as WasiCliStdout024 from './interfaces/wasi-cli-stdout.js'; // import wasi:cli/stdout@0.2.4
7
+ export type * as WasiClocksWallClock024 from './interfaces/wasi-clocks-wall-clock.js'; // import wasi:clocks/wall-clock@0.2.4
8
+ export type * as WasiFilesystemPreopens024 from './interfaces/wasi-filesystem-preopens.js'; // import wasi:filesystem/preopens@0.2.4
9
+ export type * as WasiFilesystemTypes024 from './interfaces/wasi-filesystem-types.js'; // import wasi:filesystem/types@0.2.4
10
+ export type * as WasiIoError024 from './interfaces/wasi-io-error.js'; // import wasi:io/error@0.2.4
11
+ export type * as WasiIoStreams024 from './interfaces/wasi-io-streams.js'; // import wasi:io/streams@0.2.4
12
+ export * as clientAuth from './interfaces/component-session-client-auth.js'; // export component:session/client-auth@0.1.0
13
+ export * as serverAuth from './interfaces/component-session-server-auth.js'; // export component:session/server-auth@0.1.0
14
+ export * as clientHandshake from './interfaces/component-session-client-handshake.js'; // export component:session/client-handshake@0.1.0
15
+ export * as serverHandshake from './interfaces/component-session-server-handshake.js'; // export component:session/server-handshake@0.1.0
16
+ export * as session from './interfaces/component-session-session.js'; // export component:session/session@0.1.0