@terminal3/t3n-sdk 0.2.1 → 0.3.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/dist/index.d.ts +41 -59
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/handlers.d.ts +9 -5
- package/dist/src/config/index.d.ts +29 -48
- package/dist/src/config/loader.d.ts +1 -4
- package/dist/src/config/types.d.ts +2 -2
- package/dist/src/index.d.ts +1 -1
- package/package.json +26 -25
package/dist/index.d.ts
CHANGED
|
@@ -587,10 +587,14 @@ declare function metamask_get_address(): Promise<string>;
|
|
|
587
587
|
*/
|
|
588
588
|
declare function eth_get_address(privateKey: string): string;
|
|
589
589
|
/**
|
|
590
|
-
* Create MlKemPublicKey handler that
|
|
591
|
-
*
|
|
590
|
+
* Create an MlKemPublicKey handler that lazily fetches the root public key
|
|
591
|
+
* from `${baseUrl}/status` on first invocation and caches the encoded
|
|
592
|
+
* response for subsequent calls.
|
|
593
|
+
*
|
|
594
|
+
* @param baseUrl - Optional explicit node URL. If omitted, falls back to the
|
|
595
|
+
* current environment default (see `getNodeUrl()`).
|
|
592
596
|
*/
|
|
593
|
-
declare function createMlKemPublicKeyHandler(): GuestToHostHandler;
|
|
597
|
+
declare function createMlKemPublicKeyHandler(baseUrl?: string): GuestToHostHandler;
|
|
594
598
|
/**
|
|
595
599
|
* Create Random handler backed by crypto.getRandomValues
|
|
596
600
|
* Note: The Rust Vec<u8> type serializes as an array of bytes, not a base64 string
|
|
@@ -599,7 +603,7 @@ declare function createRandomHandler(): GuestToHostHandler;
|
|
|
599
603
|
/**
|
|
600
604
|
* Create the default handler set required by the T3n handshake
|
|
601
605
|
*/
|
|
602
|
-
declare function createDefaultHandlers(): GuestToHostHandlers;
|
|
606
|
+
declare function createDefaultHandlers(baseUrl?: string): GuestToHostHandlers;
|
|
603
607
|
|
|
604
608
|
/**
|
|
605
609
|
* Cryptographic utilities for T3n SDK
|
|
@@ -724,8 +728,8 @@ type Environment = "local" | "staging" | "production" | "test";
|
|
|
724
728
|
interface SdkConfig {
|
|
725
729
|
/** Environment identifier */
|
|
726
730
|
environment: Environment;
|
|
727
|
-
/**
|
|
728
|
-
|
|
731
|
+
/** Resolved node URL (used both for RPC and for fetching the ML-KEM key) */
|
|
732
|
+
nodeUrl: string;
|
|
729
733
|
/** Configuration version */
|
|
730
734
|
version: string;
|
|
731
735
|
}
|
|
@@ -738,10 +742,7 @@ interface ConfigValidationResult {
|
|
|
738
742
|
}
|
|
739
743
|
|
|
740
744
|
/**
|
|
741
|
-
* Configuration
|
|
742
|
-
*
|
|
743
|
-
* This module provides configuration validation utilities.
|
|
744
|
-
* All environment keys are included in the bundle, and runtime selection is done via setEnvironment().
|
|
745
|
+
* Configuration validation for T3n SDK
|
|
745
746
|
*/
|
|
746
747
|
|
|
747
748
|
/**
|
|
@@ -752,68 +753,49 @@ declare function validateConfig(config: unknown): ConfigValidationResult;
|
|
|
752
753
|
/**
|
|
753
754
|
* Configuration entry point for T3n SDK
|
|
754
755
|
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
* - All keys (local, staging, production, test) are included in the bundle
|
|
760
|
-
* - Default environment is "production"
|
|
761
|
-
* - Use setEnvironment(env) to change the active key at runtime
|
|
762
|
-
*
|
|
763
|
-
* Binary files are converted to base64 strings at build time by the rollup binary plugin.
|
|
764
|
-
* In development mode (when running with tsx), files are read from the filesystem.
|
|
756
|
+
* The SDK no longer bundles ML-KEM root public keys. Instead, the active node
|
|
757
|
+
* URL is derived from the current environment (or an explicit override / the
|
|
758
|
+
* client's `baseUrl`), and the ML-KEM public key is fetched lazily from
|
|
759
|
+
* `${nodeUrl}/status` (`encaps_key` field) and cached per-URL.
|
|
765
760
|
*/
|
|
766
761
|
|
|
767
762
|
/**
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* This function allows engineers to configure which ML-KEM public key
|
|
771
|
-
* should be used at runtime. All keys are included in the bundle, so
|
|
772
|
-
* switching environments doesn't require rebuilding.
|
|
773
|
-
*
|
|
774
|
-
* @param env - The environment identifier (local, staging, production, or test)
|
|
775
|
-
* @throws Error if the environment is invalid
|
|
776
|
-
*
|
|
777
|
-
* @example
|
|
778
|
-
* ```typescript
|
|
779
|
-
* import { setEnvironment } from '@terminal3/t3n-sdk';
|
|
780
|
-
*
|
|
781
|
-
* // Use staging environment
|
|
782
|
-
* setEnvironment('staging');
|
|
783
|
-
* ```
|
|
763
|
+
* Default node URLs per environment. Override at runtime via `setNodeUrl()`
|
|
764
|
+
* or by passing `baseUrl` to `T3nClient`.
|
|
784
765
|
*/
|
|
785
|
-
declare
|
|
766
|
+
declare const NODE_URLS: Record<Environment, string>;
|
|
786
767
|
/**
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
* Returns the currently active environment, which defaults to "production".
|
|
790
|
-
* Use setEnvironment() to change the active environment.
|
|
791
|
-
*
|
|
792
|
-
* @returns The current environment identifier
|
|
768
|
+
* Set the active environment. Clears any previous URL override and the key
|
|
769
|
+
* cache so the next fetch uses the new environment's default URL.
|
|
793
770
|
*/
|
|
771
|
+
declare function setEnvironment(env: Environment): void;
|
|
794
772
|
declare function getEnvironment(): Environment;
|
|
773
|
+
declare function getEnvironmentName(): string;
|
|
795
774
|
/**
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
* Returns the SDK configuration with the ML-KEM public key for the
|
|
799
|
-
* currently active environment (set via setEnvironment()).
|
|
775
|
+
* Override the node URL for the current process. Pass `null` to clear and
|
|
776
|
+
* fall back to the environment default.
|
|
800
777
|
*
|
|
801
|
-
*
|
|
778
|
+
* Always clears the per-URL key cache, including the `setNodeUrl(sameUrl)`
|
|
779
|
+
* case — that's the explicit "force a refresh after a node-side ML-KEM
|
|
780
|
+
* rotation" entry point. Keeping a no-op-call optimization here would
|
|
781
|
+
* silently defeat that contract; an extra fetch on a no-op call is cheap.
|
|
802
782
|
*/
|
|
803
|
-
declare function
|
|
783
|
+
declare function setNodeUrl(url: string | null): void;
|
|
784
|
+
/** Resolve the active node URL: explicit `baseUrl` > override > env default. */
|
|
785
|
+
declare function getNodeUrl(baseUrl?: string): string;
|
|
804
786
|
/**
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
* @returns The base64-encoded ML-KEM public key for the current environment
|
|
787
|
+
* Fetch the ML-KEM root public key from `${nodeUrl}/status`. Cached per URL.
|
|
788
|
+
* The node must be in the `Ready` phase and expose `encaps_key`.
|
|
809
789
|
*/
|
|
810
|
-
declare function
|
|
790
|
+
declare function fetchMlKemPublicKey(baseUrl?: string): Promise<string>;
|
|
791
|
+
/** Clear the cached ML-KEM public keys. Useful in tests. */
|
|
792
|
+
declare function clearKeyCache(): void;
|
|
811
793
|
/**
|
|
812
|
-
*
|
|
813
|
-
*
|
|
814
|
-
*
|
|
794
|
+
* Return the resolved SDK configuration for the current environment.
|
|
795
|
+
* Note: this no longer includes the ML-KEM key — fetch it via
|
|
796
|
+
* `fetchMlKemPublicKey()`.
|
|
815
797
|
*/
|
|
816
|
-
declare function
|
|
798
|
+
declare function loadConfig(baseUrl?: string): SdkConfig;
|
|
817
799
|
|
|
818
|
-
export { AuthMethod, AuthenticationError, HandshakeError, HttpTransport, LogLevel, MockTransport, RpcError, SessionStateError, SessionStatus, T3nClient, T3nError, WasmError, bytesToString, createDefaultHandlers, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createRandomHandler, decodeWasmErrorMessage, eth_get_address, extractWasmError, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger,
|
|
800
|
+
export { AuthMethod, AuthenticationError, HandshakeError, HttpTransport, LogLevel, MockTransport, NODE_URLS, RpcError, SessionStateError, SessionStatus, T3nClient, T3nError, WasmError, bytesToString, clearKeyCache, createDefaultHandlers, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createRandomHandler, decodeWasmErrorMessage, eth_get_address, extractWasmError, fetchMlKemPublicKey, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, loadConfig, loadWasmComponent, metamask_get_address, metamask_sign, redactSecrets, redactSecretsFromJson, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, validateConfig };
|
|
819
801
|
export type { AuthInput, ClientAuth, ClientHandshake, ConfigValidationResult, Did, Environment, EthAuthInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, Logger, OidcAuthInput, OidcCredentials, SdkConfig, SessionCrypto, SessionId, T3nClientConfig, Transport, WasmComponent, WasmNextResult };
|