@terminal3/t3n-sdk 0.6.0 → 0.8.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 +121 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/actions.d.ts +5 -0
- package/dist/src/client/t3n-client.d.ts +19 -1
- package/dist/src/config/index.d.ts +36 -2
- package/dist/src/index.d.ts +2 -2
- package/dist/src/types/auth.d.ts +7 -2
- package/dist/src/wasm/quote-verifier/quote_verifier_bytes.d.ts +1 -0
- package/dist/src/wasm/quote-verifier-loader.d.ts +58 -0
- package/dist/wasm/generated/interfaces/component-session-server-auth.d.ts +2 -1
- package/dist/wasm/generated/session.core.wasm +0 -0
- package/dist/wasm/generated/session.js +4119 -794
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -278,11 +278,16 @@ declare enum AuthMethod {
|
|
|
278
278
|
OIDC = "oidc"
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
|
-
* OIDC credentials interface
|
|
281
|
+
* OIDC credentials interface.
|
|
282
|
+
*
|
|
283
|
+
* The TEE generates a session-binding nonce that must be included in
|
|
284
|
+
* the Google authorization URL (`&nonce=…`). The `getIdToken` callback
|
|
285
|
+
* receives this nonce and must return the `id_token` JWT obtained
|
|
286
|
+
* from the OIDC provider with the nonce baked into its claims.
|
|
282
287
|
*/
|
|
283
288
|
interface OidcCredentials {
|
|
284
289
|
provider: string;
|
|
285
|
-
|
|
290
|
+
getIdToken: (nonce: string) => Promise<string>;
|
|
286
291
|
}
|
|
287
292
|
/**
|
|
288
293
|
* Base authentication input with method discriminator
|
|
@@ -522,9 +527,27 @@ declare class T3nClient {
|
|
|
522
527
|
*/
|
|
523
528
|
handshake(): Promise<HandshakeResult>;
|
|
524
529
|
/**
|
|
525
|
-
* Authenticate with the T3n node
|
|
530
|
+
* Authenticate with the T3n node.
|
|
531
|
+
*
|
|
532
|
+
* For OIDC, this runs a two-step nonce-bound flow:
|
|
533
|
+
* 1. Sends `InitOidcAuth` to server → receives session-binding nonce.
|
|
534
|
+
* 2. Calls `getIdToken(nonce)` callback so the app can include the
|
|
535
|
+
* nonce in the Google authorization URL.
|
|
536
|
+
* 3. Sends `SubmitIdToken` with the nonce-bearing token → receives DID.
|
|
526
537
|
*/
|
|
527
538
|
authenticate(authInput: AuthInput): Promise<Did>;
|
|
539
|
+
/**
|
|
540
|
+
* OIDC two-step authentication with session-binding nonce.
|
|
541
|
+
*
|
|
542
|
+
* Bypasses the WASM client state machine and makes two encrypted
|
|
543
|
+
* RPC calls directly:
|
|
544
|
+
* 1. `InitOidcAuth { provider }` → server generates nonce → returns
|
|
545
|
+
* `ProvideNonce { nonce }`.
|
|
546
|
+
* 2. App calls `getIdToken(nonce)` to obtain a nonce-bound `id_token`.
|
|
547
|
+
* 3. `SubmitIdToken { id_token }` → server verifies token + nonce →
|
|
548
|
+
* returns `Finish { did }`.
|
|
549
|
+
*/
|
|
550
|
+
private authenticateOidc;
|
|
528
551
|
/**
|
|
529
552
|
* Execute an action on the T3n node
|
|
530
553
|
*/
|
|
@@ -766,6 +789,65 @@ interface ConfigValidationResult {
|
|
|
766
789
|
errors: string[];
|
|
767
790
|
}
|
|
768
791
|
|
|
792
|
+
/**
|
|
793
|
+
* TDX quote verifier backed by the Rust `signature` crate compiled to
|
|
794
|
+
* WASM. Full cryptographic verification: ECDSA P-256 attestation-key
|
|
795
|
+
* signature, PCK certificate chain walk to Intel's root CA, and
|
|
796
|
+
* report_data + RTMR comparison.
|
|
797
|
+
*
|
|
798
|
+
* The WASM bytes are inlined as base64 (see quote_verifier_bytes.ts)
|
|
799
|
+
* so the SDK works without bundler WASM plugins and without runtime
|
|
800
|
+
* asset URL resolution.
|
|
801
|
+
*/
|
|
802
|
+
interface QuoteVerifyResult {
|
|
803
|
+
valid: boolean;
|
|
804
|
+
error?: string;
|
|
805
|
+
rtmr3?: string;
|
|
806
|
+
report_data?: string;
|
|
807
|
+
}
|
|
808
|
+
interface PeerQuoteResult {
|
|
809
|
+
peer_id: string;
|
|
810
|
+
valid: boolean;
|
|
811
|
+
error?: string;
|
|
812
|
+
rtmr3?: string;
|
|
813
|
+
}
|
|
814
|
+
interface DkgVerifyResult {
|
|
815
|
+
valid: boolean;
|
|
816
|
+
results: PeerQuoteResult[];
|
|
817
|
+
valid_count: number;
|
|
818
|
+
expected_count: number;
|
|
819
|
+
error?: string;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Verify a single TDX attestation quote with full cryptographic verification.
|
|
823
|
+
*
|
|
824
|
+
* @param quoteB64 - Base64-encoded raw TDX v4 quote
|
|
825
|
+
* @param attestationMsgB64 - Base64-encoded attestation message
|
|
826
|
+
* (for DKG: encaps_key || sorted_peer_id_bytes)
|
|
827
|
+
* @param expectedRtmr3B64 - Optional base64-encoded 48-byte RTMR3
|
|
828
|
+
* @returns Verification result with extracted measurements
|
|
829
|
+
*/
|
|
830
|
+
declare function verifyTdxQuote(quoteB64: string, attestationMsgB64: string, expectedRtmr3B64?: string): Promise<QuoteVerifyResult>;
|
|
831
|
+
/**
|
|
832
|
+
* Verify a full DKG attestation bundle: multiple TDX quotes from all
|
|
833
|
+
* participating nodes, plus the binding between the quotes and the
|
|
834
|
+
* ML-KEM encapsulation key. Checks:
|
|
835
|
+
* 1. attestationMsg starts with encapsKey (server can't swap the key)
|
|
836
|
+
* 2. Every quote's ECDSA signature chains to Intel's SGX root CA
|
|
837
|
+
* 3. Every quote's report_data == keccak512(attestationMsg)
|
|
838
|
+
* 4. Optional RTMR3 pinning per quote
|
|
839
|
+
*
|
|
840
|
+
* @param encapsKeyB64 - Base64-encoded ML-KEM encapsulation key
|
|
841
|
+
* (from `/status.encaps_key`)
|
|
842
|
+
* @param attestationMsgB64 - Base64-encoded raw attestation message
|
|
843
|
+
* (from `/status.dkg_attestation.attestation_msg`)
|
|
844
|
+
* @param peerIds - Sorted array of base58 peer IDs
|
|
845
|
+
* @param quotes - Map of peer_id → base64-encoded TDX quote
|
|
846
|
+
* @param expectedRtmr3B64 - Optional base64-encoded 48-byte RTMR3
|
|
847
|
+
* @returns Per-peer verification results and overall validity
|
|
848
|
+
*/
|
|
849
|
+
declare function verifyDkgAttestation(encapsKeyB64: string, attestationMsgB64: string, peerIds: string[], quotes: Record<string, string>, expectedRtmr3B64?: string): Promise<DkgVerifyResult>;
|
|
850
|
+
|
|
769
851
|
/**
|
|
770
852
|
* Configuration validation for T3n SDK
|
|
771
853
|
*/
|
|
@@ -789,6 +871,18 @@ declare function validateConfig(config: unknown): ConfigValidationResult;
|
|
|
789
871
|
* or by passing `baseUrl` to `T3nClient`.
|
|
790
872
|
*/
|
|
791
873
|
declare const NODE_URLS: Record<Environment, string>;
|
|
874
|
+
/** DKG attestation bundle from the cluster. */
|
|
875
|
+
interface DkgAttestation {
|
|
876
|
+
/** Sorted base58 peer IDs that participated in DKG. */
|
|
877
|
+
peer_ids: string[];
|
|
878
|
+
/** Per-node TDX quotes keyed by base58 peer ID (base64-encoded). */
|
|
879
|
+
quotes: Record<string, string>;
|
|
880
|
+
/**
|
|
881
|
+
* Base64-encoded raw attestation message: `encaps_key || sorted_peer_ids`.
|
|
882
|
+
* Each quote's `report_data` is `keccak512(attestation_msg)`.
|
|
883
|
+
*/
|
|
884
|
+
attestation_msg: string;
|
|
885
|
+
}
|
|
792
886
|
/**
|
|
793
887
|
* Set the active environment. Clears any previous URL override and the key
|
|
794
888
|
* cache so the next fetch uses the new environment's default URL.
|
|
@@ -809,10 +903,30 @@ declare function setNodeUrl(url: string | null): void;
|
|
|
809
903
|
/** Resolve the active node URL: explicit `baseUrl` > override > env default. */
|
|
810
904
|
declare function getNodeUrl(baseUrl?: string): string;
|
|
811
905
|
/**
|
|
812
|
-
* Fetch the ML-KEM root public key from `${nodeUrl}/status`. Cached
|
|
813
|
-
*
|
|
906
|
+
* Fetch the ML-KEM root public key from `${nodeUrl}/status`. Cached
|
|
907
|
+
* per URL because the key is stable for the cluster's lifetime (a
|
|
908
|
+
* new DKG means a full redeploy; callers clear the cache via
|
|
909
|
+
* `clearKeyCache()` or `setNodeUrl()` in that case).
|
|
910
|
+
*
|
|
911
|
+
* Returns only the base64-encoded key. For the DKG attestation
|
|
912
|
+
* bundle (which changes over time as peer quotes replicate via
|
|
913
|
+
* Raft), call `fetchDkgAttestation()` \u2014 that path is
|
|
914
|
+
* intentionally uncached.
|
|
814
915
|
*/
|
|
815
916
|
declare function fetchMlKemPublicKey(baseUrl?: string): Promise<string>;
|
|
917
|
+
/**
|
|
918
|
+
* Fetch the DKG attestation bundle from `${nodeUrl}/status`. Never
|
|
919
|
+
* cached \u2014 peer quotes are written to consensus KV asynchronously
|
|
920
|
+
* during cluster bootstrap, so early reads may see a subset of the
|
|
921
|
+
* expected quotes. Caching would pin an incomplete bundle and cause
|
|
922
|
+
* spurious `valid_count < expected_count` failures in
|
|
923
|
+
* `verifyDkgAttestation()` for the whole process lifetime.
|
|
924
|
+
*
|
|
925
|
+
* Returns `undefined` when the node has not yet published an
|
|
926
|
+
* attestation (e.g. still bootstrapping, or running with a mock
|
|
927
|
+
* signer where attestation is skipped by design).
|
|
928
|
+
*/
|
|
929
|
+
declare function fetchDkgAttestation(baseUrl?: string): Promise<DkgAttestation | undefined>;
|
|
816
930
|
/** Clear the cached ML-KEM public keys. Useful in tests. */
|
|
817
931
|
declare function clearKeyCache(): void;
|
|
818
932
|
/**
|
|
@@ -822,5 +936,5 @@ declare function clearKeyCache(): void;
|
|
|
822
936
|
*/
|
|
823
937
|
declare function loadConfig(baseUrl?: string): SdkConfig;
|
|
824
938
|
|
|
825
|
-
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 };
|
|
826
|
-
export type { AuthInput, ClientAuth, ClientHandshake, ConfigValidationResult, Did, Environment, EthAuthInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, Logger, OidcAuthInput, OidcCredentials, SdkConfig, SessionCrypto, SessionId, T3nClientConfig, Transport, WasmComponent, WasmNextResult };
|
|
939
|
+
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, fetchDkgAttestation, fetchMlKemPublicKey, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, loadConfig, loadWasmComponent, metamask_get_address, metamask_sign, redactSecrets, redactSecretsFromJson, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, validateConfig, verifyDkgAttestation, verifyTdxQuote };
|
|
940
|
+
export type { AuthInput, ClientAuth, ClientHandshake, ConfigValidationResult, Did, DkgAttestation, DkgVerifyResult, Environment, EthAuthInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, Logger, OidcAuthInput, OidcCredentials, PeerQuoteResult, QuoteVerifyResult, SdkConfig, SessionCrypto, SessionId, T3nClientConfig, Transport, WasmComponent, WasmNextResult };
|