@terminal3/t3n-sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +29 -15
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/handlers.d.ts +10 -1
- package/dist/src/client/transport.d.ts +4 -4
- package/dist/src/types/index.d.ts +9 -2
- package/dist/src/utils/logger.d.ts +4 -4
- package/dist/src/utils/redaction.d.ts +1 -1
- package/dist/src/wasm/interface.d.ts +1 -2
- package/dist/src/wasm/loader.d.ts +1 -1
- package/dist/wasm/generated/interfaces/component-session-cookie.d.ts +8 -0
- package/dist/wasm/generated/interfaces/component-session-session.d.ts +1 -2
- package/dist/wasm/generated/interfaces/wasi-cli-environment.d.ts +1 -1
- package/dist/wasm/generated/interfaces/wasi-cli-exit.d.ts +1 -1
- package/dist/wasm/generated/interfaces/wasi-cli-stderr.d.ts +1 -1
- package/dist/wasm/generated/interfaces/wasi-io-error.d.ts +2 -1
- package/dist/wasm/generated/interfaces/wasi-io-streams.d.ts +1 -11
- package/dist/wasm/generated/interfaces/wasi-random-random.d.ts +2 -0
- package/dist/wasm/generated/session.core.wasm +0 -0
- package/dist/wasm/generated/session.d.ts +7 -10
- package/dist/wasm/generated/session.js +239 -1674
- package/package.json +1 -1
- package/dist/wasm/generated/interfaces/wasi-cli-stdin.d.ts +0 -3
- package/dist/wasm/generated/interfaces/wasi-cli-stdout.d.ts +0 -3
- package/dist/wasm/generated/interfaces/wasi-clocks-wall-clock.d.ts +0 -5
- package/dist/wasm/generated/interfaces/wasi-filesystem-preopens.d.ts +0 -3
- package/dist/wasm/generated/interfaces/wasi-filesystem-types.d.ts +0 -124
- package/dist/wasm/generated/session.core2.wasm +0 -0
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { GuestToHostHandler, GuestToHostHandlers } from "../types";
|
|
8
8
|
import { Logger } from "../utils/logger";
|
|
9
|
+
/**
|
|
10
|
+
* Account — MetaMask handler accepts either a plain address string or an
|
|
11
|
+
* object with an `address` field (for compatibility with various wallet
|
|
12
|
+
* libraries).
|
|
13
|
+
*/
|
|
14
|
+
type EthAccount = string | {
|
|
15
|
+
address: string;
|
|
16
|
+
};
|
|
9
17
|
/**
|
|
10
18
|
* Create an EthSign handler using MetaMask (window.ethereum)
|
|
11
19
|
* @param account - MetaMask account (string address or object with address property)
|
|
@@ -13,7 +21,7 @@ import { Logger } from "../utils/logger";
|
|
|
13
21
|
* Pass a custom logger to override logging behavior for this handler.
|
|
14
22
|
* @param privateKey - Optional private key for signing (if provided, MetaMask is not used)
|
|
15
23
|
*/
|
|
16
|
-
export declare function metamask_sign(account:
|
|
24
|
+
export declare function metamask_sign(account: EthAccount, logger?: Logger, privateKey?: string | undefined): GuestToHostHandler;
|
|
17
25
|
/**
|
|
18
26
|
* Get the current MetaMask address
|
|
19
27
|
* @returns Ethereum address (lowercase, 0x prefixed)
|
|
@@ -62,3 +70,4 @@ export declare function createDefaultHandlers(baseUrl: string): GuestToHostHandl
|
|
|
62
70
|
* ML-KEM key fetch hits the right node.
|
|
63
71
|
*/
|
|
64
72
|
export declare function mergeWithDefaultHandlers(handlers: GuestToHostHandlers | undefined, baseUrl: string): GuestToHostHandlers;
|
|
73
|
+
export {};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export interface JsonRpcRequest {
|
|
11
11
|
jsonrpc: "2.0";
|
|
12
12
|
method: string;
|
|
13
|
-
params:
|
|
13
|
+
params: unknown;
|
|
14
14
|
id: string | number;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -18,11 +18,11 @@ export interface JsonRpcRequest {
|
|
|
18
18
|
*/
|
|
19
19
|
export interface JsonRpcResponse {
|
|
20
20
|
jsonrpc: "2.0";
|
|
21
|
-
result?:
|
|
21
|
+
result?: unknown;
|
|
22
22
|
error?: {
|
|
23
23
|
code: number;
|
|
24
24
|
message: string;
|
|
25
|
-
data?:
|
|
25
|
+
data?: unknown;
|
|
26
26
|
};
|
|
27
27
|
id: string | number;
|
|
28
28
|
}
|
|
@@ -84,7 +84,7 @@ export declare class MockTransport implements Transport {
|
|
|
84
84
|
/**
|
|
85
85
|
* Mock an error response for a specific method
|
|
86
86
|
*/
|
|
87
|
-
mockError(method: string, code: number, message: string, data?:
|
|
87
|
+
mockError(method: string, code: number, message: string, data?: unknown): void;
|
|
88
88
|
/**
|
|
89
89
|
* Get all requests that were sent
|
|
90
90
|
*/
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Guest-to-Host request handler function type
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Handles requests from WASM guest that need host (SDK) to perform side
|
|
8
|
+
* effects. The exact shape of `requestData` depends on the specific
|
|
9
|
+
* handler — see `GuestToHostHandlers` below for the per-handler shapes.
|
|
10
|
+
* The wrapper layer in `T3nClient.handleGuestToHost` parses the JSON
|
|
11
|
+
* envelope and calls the matching handler with the parsed data, so
|
|
12
|
+
* each handler's implementation should narrow `requestData` to its
|
|
13
|
+
* own expected shape.
|
|
7
14
|
*/
|
|
8
|
-
export type GuestToHostHandler = (requestData:
|
|
15
|
+
export type GuestToHostHandler = (requestData: Record<string, unknown>) => Promise<Uint8Array>;
|
|
9
16
|
/**
|
|
10
17
|
* Map of guest-to-host request handlers
|
|
11
18
|
* Keys match the guest_to_host tag values from the WASM
|
|
@@ -49,22 +49,22 @@ export interface Logger {
|
|
|
49
49
|
* Log a debug message (most verbose)
|
|
50
50
|
* @param args - Arguments to log
|
|
51
51
|
*/
|
|
52
|
-
debug(...args:
|
|
52
|
+
debug(...args: unknown[]): void;
|
|
53
53
|
/**
|
|
54
54
|
* Log an info message
|
|
55
55
|
* @param args - Arguments to log
|
|
56
56
|
*/
|
|
57
|
-
info(...args:
|
|
57
|
+
info(...args: unknown[]): void;
|
|
58
58
|
/**
|
|
59
59
|
* Log a warning message
|
|
60
60
|
* @param args - Arguments to log
|
|
61
61
|
*/
|
|
62
|
-
warn(...args:
|
|
62
|
+
warn(...args: unknown[]): void;
|
|
63
63
|
/**
|
|
64
64
|
* Log an error message (least verbose)
|
|
65
65
|
* @param args - Arguments to log
|
|
66
66
|
*/
|
|
67
|
-
error(...args:
|
|
67
|
+
error(...args: unknown[]): void;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Set the global default log level for all components
|
|
@@ -75,11 +75,10 @@ export interface SessionCrypto {
|
|
|
75
75
|
/**
|
|
76
76
|
* Encrypt plaintext using session
|
|
77
77
|
* @param session - Session state (opaque bytes)
|
|
78
|
-
* @param nonce - Nonce to use for encryption
|
|
79
78
|
* @param plaintext - Data to encrypt
|
|
80
79
|
* @returns Promise with encrypted bytes
|
|
81
80
|
*/
|
|
82
|
-
encrypt(session: Uint8Array,
|
|
81
|
+
encrypt(session: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
|
|
83
82
|
/**
|
|
84
83
|
* Decrypt ciphertext using session
|
|
85
84
|
* @param session - Session state (opaque bytes)
|
|
@@ -16,7 +16,7 @@ export interface WasmLoadConfig {
|
|
|
16
16
|
/** Custom fetch function for loading WASM */
|
|
17
17
|
fetchFn?: typeof fetch;
|
|
18
18
|
/** Additional initialization options */
|
|
19
|
-
initOptions?: Record<string,
|
|
19
|
+
initOptions?: Record<string, unknown>;
|
|
20
20
|
/** Optional logger instance - if not provided, uses global default */
|
|
21
21
|
logger?: Logger;
|
|
22
22
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @module Interface component:session/cookie@0.1.0 **/
|
|
2
|
+
export function validate(cookieValue: string, teeAddress: Uint8Array, nowSec: bigint): Validation;
|
|
3
|
+
export interface Validation {
|
|
4
|
+
authenticated: boolean,
|
|
5
|
+
did?: string,
|
|
6
|
+
exp: bigint,
|
|
7
|
+
}
|
|
8
|
+
export type Error = Uint8Array;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @module Interface component:session/session@0.1.0 **/
|
|
2
|
-
export function encrypt(session: Session,
|
|
2
|
+
export function encrypt(session: Session, plaintext: Plaintext): Ciphertext;
|
|
3
3
|
export function decrypt(session: Session, ciphertext: Ciphertext): Plaintext;
|
|
4
4
|
export type Error = Uint8Array;
|
|
5
5
|
export type Session = Uint8Array;
|
|
6
6
|
export type Plaintext = Uint8Array;
|
|
7
7
|
export type Ciphertext = Uint8Array;
|
|
8
|
-
export type Nonce = Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @module Interface wasi:cli/environment@0.2.
|
|
1
|
+
/** @module Interface wasi:cli/environment@0.2.9 **/
|
|
2
2
|
export function getEnvironment(): Array<[string, string]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module Interface wasi:io/streams@0.2.
|
|
1
|
+
/** @module Interface wasi:io/streams@0.2.9 **/
|
|
2
2
|
export type Error = import('./wasi-io-error.js').Error;
|
|
3
3
|
export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
|
|
4
4
|
export interface StreamErrorLastOperationFailed {
|
|
@@ -9,20 +9,10 @@ export interface StreamErrorClosed {
|
|
|
9
9
|
tag: 'closed',
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export class InputStream {
|
|
13
|
-
/**
|
|
14
|
-
* This type does not have a public constructor.
|
|
15
|
-
*/
|
|
16
|
-
private constructor();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
12
|
export class OutputStream {
|
|
20
13
|
/**
|
|
21
14
|
* This type does not have a public constructor.
|
|
22
15
|
*/
|
|
23
16
|
private constructor();
|
|
24
|
-
checkWrite(): bigint;
|
|
25
|
-
write(contents: Uint8Array): void;
|
|
26
17
|
blockingWriteAndFlush(contents: Uint8Array): void;
|
|
27
|
-
blockingFlush(): void;
|
|
28
18
|
}
|
|
Binary file
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
// world root:component/root
|
|
2
|
-
export type * as
|
|
3
|
-
export type * as
|
|
4
|
-
export type * as
|
|
5
|
-
export type * as
|
|
6
|
-
export type * as
|
|
7
|
-
export type * as
|
|
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
|
|
2
|
+
export type * as WasiCliEnvironment029 from './interfaces/wasi-cli-environment.js'; // import wasi:cli/environment@0.2.9
|
|
3
|
+
export type * as WasiCliExit029 from './interfaces/wasi-cli-exit.js'; // import wasi:cli/exit@0.2.9
|
|
4
|
+
export type * as WasiCliStderr029 from './interfaces/wasi-cli-stderr.js'; // import wasi:cli/stderr@0.2.9
|
|
5
|
+
export type * as WasiIoError029 from './interfaces/wasi-io-error.js'; // import wasi:io/error@0.2.9
|
|
6
|
+
export type * as WasiIoStreams029 from './interfaces/wasi-io-streams.js'; // import wasi:io/streams@0.2.9
|
|
7
|
+
export type * as WasiRandomRandom029 from './interfaces/wasi-random-random.js'; // import wasi:random/random@0.2.9
|
|
12
8
|
export * as clientAuth from './interfaces/component-session-client-auth.js'; // export component:session/client-auth@0.1.0
|
|
13
9
|
export * as serverAuth from './interfaces/component-session-server-auth.js'; // export component:session/server-auth@0.1.0
|
|
14
10
|
export * as clientHandshake from './interfaces/component-session-client-handshake.js'; // export component:session/client-handshake@0.1.0
|
|
15
11
|
export * as serverHandshake from './interfaces/component-session-server-handshake.js'; // export component:session/server-handshake@0.1.0
|
|
16
12
|
export * as session from './interfaces/component-session-session.js'; // export component:session/session@0.1.0
|
|
13
|
+
export * as cookie from './interfaces/component-session-cookie.js'; // export component:session/cookie@0.1.0
|