@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
package/dist/index.d.ts
CHANGED
|
@@ -155,22 +155,22 @@ interface Logger {
|
|
|
155
155
|
* Log a debug message (most verbose)
|
|
156
156
|
* @param args - Arguments to log
|
|
157
157
|
*/
|
|
158
|
-
debug(...args:
|
|
158
|
+
debug(...args: unknown[]): void;
|
|
159
159
|
/**
|
|
160
160
|
* Log an info message
|
|
161
161
|
* @param args - Arguments to log
|
|
162
162
|
*/
|
|
163
|
-
info(...args:
|
|
163
|
+
info(...args: unknown[]): void;
|
|
164
164
|
/**
|
|
165
165
|
* Log a warning message
|
|
166
166
|
* @param args - Arguments to log
|
|
167
167
|
*/
|
|
168
|
-
warn(...args:
|
|
168
|
+
warn(...args: unknown[]): void;
|
|
169
169
|
/**
|
|
170
170
|
* Log an error message (least verbose)
|
|
171
171
|
* @param args - Arguments to log
|
|
172
172
|
*/
|
|
173
|
-
error(...args:
|
|
173
|
+
error(...args: unknown[]): void;
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Set the global default log level for all components
|
|
@@ -224,7 +224,7 @@ interface WasmLoadConfig {
|
|
|
224
224
|
/** Custom fetch function for loading WASM */
|
|
225
225
|
fetchFn?: typeof fetch;
|
|
226
226
|
/** Additional initialization options */
|
|
227
|
-
initOptions?: Record<string,
|
|
227
|
+
initOptions?: Record<string, unknown>;
|
|
228
228
|
/** Optional logger instance - if not provided, uses global default */
|
|
229
229
|
logger?: Logger;
|
|
230
230
|
}
|
|
@@ -320,9 +320,16 @@ declare function createOidcAuthInput(credentials: OidcCredentials): OidcAuthInpu
|
|
|
320
320
|
*/
|
|
321
321
|
/**
|
|
322
322
|
* Guest-to-Host request handler function type
|
|
323
|
-
*
|
|
323
|
+
*
|
|
324
|
+
* Handles requests from WASM guest that need host (SDK) to perform side
|
|
325
|
+
* effects. The exact shape of `requestData` depends on the specific
|
|
326
|
+
* handler — see `GuestToHostHandlers` below for the per-handler shapes.
|
|
327
|
+
* The wrapper layer in `T3nClient.handleGuestToHost` parses the JSON
|
|
328
|
+
* envelope and calls the matching handler with the parsed data, so
|
|
329
|
+
* each handler's implementation should narrow `requestData` to its
|
|
330
|
+
* own expected shape.
|
|
324
331
|
*/
|
|
325
|
-
type GuestToHostHandler = (requestData:
|
|
332
|
+
type GuestToHostHandler = (requestData: Record<string, unknown>) => Promise<Uint8Array>;
|
|
326
333
|
/**
|
|
327
334
|
* Map of guest-to-host request handlers
|
|
328
335
|
* Keys match the guest_to_host tag values from the WASM
|
|
@@ -361,7 +368,7 @@ interface GuestToHostHandlers {
|
|
|
361
368
|
interface JsonRpcRequest {
|
|
362
369
|
jsonrpc: "2.0";
|
|
363
370
|
method: string;
|
|
364
|
-
params:
|
|
371
|
+
params: unknown;
|
|
365
372
|
id: string | number;
|
|
366
373
|
}
|
|
367
374
|
/**
|
|
@@ -369,11 +376,11 @@ interface JsonRpcRequest {
|
|
|
369
376
|
*/
|
|
370
377
|
interface JsonRpcResponse {
|
|
371
378
|
jsonrpc: "2.0";
|
|
372
|
-
result?:
|
|
379
|
+
result?: unknown;
|
|
373
380
|
error?: {
|
|
374
381
|
code: number;
|
|
375
382
|
message: string;
|
|
376
|
-
data?:
|
|
383
|
+
data?: unknown;
|
|
377
384
|
};
|
|
378
385
|
id: string | number;
|
|
379
386
|
}
|
|
@@ -435,7 +442,7 @@ declare class MockTransport implements Transport {
|
|
|
435
442
|
/**
|
|
436
443
|
* Mock an error response for a specific method
|
|
437
444
|
*/
|
|
438
|
-
mockError(method: string, code: number, message: string, data?:
|
|
445
|
+
mockError(method: string, code: number, message: string, data?: unknown): void;
|
|
439
446
|
/**
|
|
440
447
|
* Get all requests that were sent
|
|
441
448
|
*/
|
|
@@ -567,6 +574,14 @@ declare class T3nClient {
|
|
|
567
574
|
* Examples: signing challenges, providing public keys, generating random bytes.
|
|
568
575
|
*/
|
|
569
576
|
|
|
577
|
+
/**
|
|
578
|
+
* Account — MetaMask handler accepts either a plain address string or an
|
|
579
|
+
* object with an `address` field (for compatibility with various wallet
|
|
580
|
+
* libraries).
|
|
581
|
+
*/
|
|
582
|
+
type EthAccount = string | {
|
|
583
|
+
address: string;
|
|
584
|
+
};
|
|
570
585
|
/**
|
|
571
586
|
* Create an EthSign handler using MetaMask (window.ethereum)
|
|
572
587
|
* @param account - MetaMask account (string address or object with address property)
|
|
@@ -574,7 +589,7 @@ declare class T3nClient {
|
|
|
574
589
|
* Pass a custom logger to override logging behavior for this handler.
|
|
575
590
|
* @param privateKey - Optional private key for signing (if provided, MetaMask is not used)
|
|
576
591
|
*/
|
|
577
|
-
declare function metamask_sign(account:
|
|
592
|
+
declare function metamask_sign(account: EthAccount, logger?: Logger, privateKey?: string | undefined): GuestToHostHandler;
|
|
578
593
|
/**
|
|
579
594
|
* Get the current MetaMask address
|
|
580
595
|
* @returns Ethereum address (lowercase, 0x prefixed)
|
|
@@ -720,7 +735,7 @@ declare function extractWasmError(error: unknown): string;
|
|
|
720
735
|
/**
|
|
721
736
|
* Redact secrets from values before logging
|
|
722
737
|
*/
|
|
723
|
-
declare function redactSecrets(value:
|
|
738
|
+
declare function redactSecrets(value: unknown): unknown;
|
|
724
739
|
/**
|
|
725
740
|
* Redact secrets from a JSON string
|
|
726
741
|
*/
|