@terminal3/t3n-sdk 0.4.0 → 0.4.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.
- package/dist/index.d.ts +28 -13
- 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/loader.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
|
}
|