@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
package/README.md
CHANGED
|
@@ -425,7 +425,7 @@ With `--provider`, the demo runs a **user update** (create/update profile) by de
|
|
|
425
425
|
|
|
426
426
|
3. **OID4VP present only** – When you pass **`--oid4vp-only --did <did>`**, the demo skips user update and sends only the OID4VP present request for the given DID.
|
|
427
427
|
|
|
428
|
-
Payloads are configurable via **defaults** or **JSON files** (`--user-update-json`, `--oid4vp-json`). The request body is signed with EIP-191 using the provider’s EOA key. The key must match
|
|
428
|
+
Payloads are configurable via **defaults** or **JSON files** (`--user-update-json`, `--oid4vp-json`). The request body is signed with EIP-191 using the provider’s EOA key. The key must match `auth_method.public_key` for the provider in the TEE's provider config. By default the demo uses the test key (`0x01`×32); override with `--provider-signing-key` or `PROVIDER_SIGNING_KEY` for other environments.
|
|
429
429
|
|
|
430
430
|
```bash
|
|
431
431
|
# User update only (default)
|
|
@@ -472,7 +472,7 @@ The demo supports the following command-line arguments:
|
|
|
472
472
|
|
|
473
473
|
- `--wait-tx`: After step 1 (user update), wait for transaction confirmation before step 2. Can also set env `WAIT_FOR_TX=true`. (Tx wait is not implemented; flag is accepted for future use.)
|
|
474
474
|
|
|
475
|
-
- `--provider-signing-key`: EOA private key (32-byte hex, e.g. `0x01...01`) for signing provider webhooks. Must match the TEE’s provider config `auth_method.public_key` for the provider. Default is the test key used in integration
|
|
475
|
+
- `--provider-signing-key`: EOA private key (32-byte hex, e.g. `0x01...01`) for signing provider webhooks. Must match the TEE’s provider config `auth_method.public_key` for the provider. Default is the test key used in integration. Can also set env `PROVIDER_SIGNING_KEY`.
|
|
476
476
|
|
|
477
477
|
- `--script-version`: Optional override for contract script version used by session-based actions (`--upsert`, `--get-profile`, `--agent-auth`). If omitted, the demo resolves the latest version dynamically from `/api/contracts/current` for `tee:user/contracts`.
|
|
478
478
|
|
package/dist/index.d.ts
CHANGED
|
@@ -75,11 +75,10 @@ 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)
|
|
@@ -155,22 +154,22 @@ interface Logger {
|
|
|
155
154
|
* Log a debug message (most verbose)
|
|
156
155
|
* @param args - Arguments to log
|
|
157
156
|
*/
|
|
158
|
-
debug(...args:
|
|
157
|
+
debug(...args: unknown[]): void;
|
|
159
158
|
/**
|
|
160
159
|
* Log an info message
|
|
161
160
|
* @param args - Arguments to log
|
|
162
161
|
*/
|
|
163
|
-
info(...args:
|
|
162
|
+
info(...args: unknown[]): void;
|
|
164
163
|
/**
|
|
165
164
|
* Log a warning message
|
|
166
165
|
* @param args - Arguments to log
|
|
167
166
|
*/
|
|
168
|
-
warn(...args:
|
|
167
|
+
warn(...args: unknown[]): void;
|
|
169
168
|
/**
|
|
170
169
|
* Log an error message (least verbose)
|
|
171
170
|
* @param args - Arguments to log
|
|
172
171
|
*/
|
|
173
|
-
error(...args:
|
|
172
|
+
error(...args: unknown[]): void;
|
|
174
173
|
}
|
|
175
174
|
/**
|
|
176
175
|
* Set the global default log level for all components
|
|
@@ -224,7 +223,7 @@ interface WasmLoadConfig {
|
|
|
224
223
|
/** Custom fetch function for loading WASM */
|
|
225
224
|
fetchFn?: typeof fetch;
|
|
226
225
|
/** Additional initialization options */
|
|
227
|
-
initOptions?: Record<string,
|
|
226
|
+
initOptions?: Record<string, unknown>;
|
|
228
227
|
/** Optional logger instance - if not provided, uses global default */
|
|
229
228
|
logger?: Logger;
|
|
230
229
|
}
|
|
@@ -320,9 +319,16 @@ declare function createOidcAuthInput(credentials: OidcCredentials): OidcAuthInpu
|
|
|
320
319
|
*/
|
|
321
320
|
/**
|
|
322
321
|
* Guest-to-Host request handler function type
|
|
323
|
-
*
|
|
322
|
+
*
|
|
323
|
+
* Handles requests from WASM guest that need host (SDK) to perform side
|
|
324
|
+
* effects. The exact shape of `requestData` depends on the specific
|
|
325
|
+
* handler — see `GuestToHostHandlers` below for the per-handler shapes.
|
|
326
|
+
* The wrapper layer in `T3nClient.handleGuestToHost` parses the JSON
|
|
327
|
+
* envelope and calls the matching handler with the parsed data, so
|
|
328
|
+
* each handler's implementation should narrow `requestData` to its
|
|
329
|
+
* own expected shape.
|
|
324
330
|
*/
|
|
325
|
-
type GuestToHostHandler = (requestData:
|
|
331
|
+
type GuestToHostHandler = (requestData: Record<string, unknown>) => Promise<Uint8Array>;
|
|
326
332
|
/**
|
|
327
333
|
* Map of guest-to-host request handlers
|
|
328
334
|
* Keys match the guest_to_host tag values from the WASM
|
|
@@ -361,7 +367,7 @@ interface GuestToHostHandlers {
|
|
|
361
367
|
interface JsonRpcRequest {
|
|
362
368
|
jsonrpc: "2.0";
|
|
363
369
|
method: string;
|
|
364
|
-
params:
|
|
370
|
+
params: unknown;
|
|
365
371
|
id: string | number;
|
|
366
372
|
}
|
|
367
373
|
/**
|
|
@@ -369,11 +375,11 @@ interface JsonRpcRequest {
|
|
|
369
375
|
*/
|
|
370
376
|
interface JsonRpcResponse {
|
|
371
377
|
jsonrpc: "2.0";
|
|
372
|
-
result?:
|
|
378
|
+
result?: unknown;
|
|
373
379
|
error?: {
|
|
374
380
|
code: number;
|
|
375
381
|
message: string;
|
|
376
|
-
data?:
|
|
382
|
+
data?: unknown;
|
|
377
383
|
};
|
|
378
384
|
id: string | number;
|
|
379
385
|
}
|
|
@@ -435,7 +441,7 @@ declare class MockTransport implements Transport {
|
|
|
435
441
|
/**
|
|
436
442
|
* Mock an error response for a specific method
|
|
437
443
|
*/
|
|
438
|
-
mockError(method: string, code: number, message: string, data?:
|
|
444
|
+
mockError(method: string, code: number, message: string, data?: unknown): void;
|
|
439
445
|
/**
|
|
440
446
|
* Get all requests that were sent
|
|
441
447
|
*/
|
|
@@ -567,6 +573,14 @@ declare class T3nClient {
|
|
|
567
573
|
* Examples: signing challenges, providing public keys, generating random bytes.
|
|
568
574
|
*/
|
|
569
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Account — MetaMask handler accepts either a plain address string or an
|
|
578
|
+
* object with an `address` field (for compatibility with various wallet
|
|
579
|
+
* libraries).
|
|
580
|
+
*/
|
|
581
|
+
type EthAccount = string | {
|
|
582
|
+
address: string;
|
|
583
|
+
};
|
|
570
584
|
/**
|
|
571
585
|
* Create an EthSign handler using MetaMask (window.ethereum)
|
|
572
586
|
* @param account - MetaMask account (string address or object with address property)
|
|
@@ -574,7 +588,7 @@ declare class T3nClient {
|
|
|
574
588
|
* Pass a custom logger to override logging behavior for this handler.
|
|
575
589
|
* @param privateKey - Optional private key for signing (if provided, MetaMask is not used)
|
|
576
590
|
*/
|
|
577
|
-
declare function metamask_sign(account:
|
|
591
|
+
declare function metamask_sign(account: EthAccount, logger?: Logger, privateKey?: string | undefined): GuestToHostHandler;
|
|
578
592
|
/**
|
|
579
593
|
* Get the current MetaMask address
|
|
580
594
|
* @returns Ethereum address (lowercase, 0x prefixed)
|
|
@@ -720,7 +734,7 @@ declare function extractWasmError(error: unknown): string;
|
|
|
720
734
|
/**
|
|
721
735
|
* Redact secrets from values before logging
|
|
722
736
|
*/
|
|
723
|
-
declare function redactSecrets(value:
|
|
737
|
+
declare function redactSecrets(value: unknown): unknown;
|
|
724
738
|
/**
|
|
725
739
|
* Redact secrets from a JSON string
|
|
726
740
|
*/
|