@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.
@@ -15,3 +15,8 @@ export declare function createHandshakeAction(): Uint8Array;
15
15
  * @param authInput - The authentication input (Ethereum or OIDC)
16
16
  */
17
17
  export declare function createAuthAction(authInput: AuthInput): Uint8Array;
18
+ /**
19
+ * Create the OIDC SubmitToken action for the second step of nonce-bound auth.
20
+ * @param idToken - The id_token JWT obtained from the OIDC provider with the nonce
21
+ */
22
+ export declare function createOidcSubmitTokenAction(idToken: string): Uint8Array;
@@ -25,9 +25,27 @@ export declare class T3nClient {
25
25
  */
26
26
  handshake(): Promise<HandshakeResult>;
27
27
  /**
28
- * Authenticate with the T3n node
28
+ * Authenticate with the T3n node.
29
+ *
30
+ * For OIDC, this runs a two-step nonce-bound flow:
31
+ * 1. Sends `InitOidcAuth` to server → receives session-binding nonce.
32
+ * 2. Calls `getIdToken(nonce)` callback so the app can include the
33
+ * nonce in the Google authorization URL.
34
+ * 3. Sends `SubmitIdToken` with the nonce-bearing token → receives DID.
29
35
  */
30
36
  authenticate(authInput: AuthInput): Promise<Did>;
37
+ /**
38
+ * OIDC two-step authentication with session-binding nonce.
39
+ *
40
+ * Bypasses the WASM client state machine and makes two encrypted
41
+ * RPC calls directly:
42
+ * 1. `InitOidcAuth { provider }` → server generates nonce → returns
43
+ * `ProvideNonce { nonce }`.
44
+ * 2. App calls `getIdToken(nonce)` to obtain a nonce-bound `id_token`.
45
+ * 3. `SubmitIdToken { id_token }` → server verifies token + nonce →
46
+ * returns `Finish { did }`.
47
+ */
48
+ private authenticateOidc;
31
49
  /**
32
50
  * Execute an action on the T3n node
33
51
  */
@@ -12,6 +12,18 @@ import type { SdkConfig, Environment } from "./types";
12
12
  * or by passing `baseUrl` to `T3nClient`.
13
13
  */
14
14
  export declare const NODE_URLS: Record<Environment, string>;
15
+ /** DKG attestation bundle from the cluster. */
16
+ export interface DkgAttestation {
17
+ /** Sorted base58 peer IDs that participated in DKG. */
18
+ peer_ids: string[];
19
+ /** Per-node TDX quotes keyed by base58 peer ID (base64-encoded). */
20
+ quotes: Record<string, string>;
21
+ /**
22
+ * Base64-encoded raw attestation message: `encaps_key || sorted_peer_ids`.
23
+ * Each quote's `report_data` is `keccak512(attestation_msg)`.
24
+ */
25
+ attestation_msg: string;
26
+ }
15
27
  /**
16
28
  * Set the active environment. Clears any previous URL override and the key
17
29
  * cache so the next fetch uses the new environment's default URL.
@@ -32,10 +44,30 @@ export declare function setNodeUrl(url: string | null): void;
32
44
  /** Resolve the active node URL: explicit `baseUrl` > override > env default. */
33
45
  export declare function getNodeUrl(baseUrl?: string): string;
34
46
  /**
35
- * Fetch the ML-KEM root public key from `${nodeUrl}/status`. Cached per URL.
36
- * The node must be in the `Ready` phase and expose `encaps_key`.
47
+ * Fetch the ML-KEM root public key from `${nodeUrl}/status`. Cached
48
+ * per URL because the key is stable for the cluster's lifetime (a
49
+ * new DKG means a full redeploy; callers clear the cache via
50
+ * `clearKeyCache()` or `setNodeUrl()` in that case).
51
+ *
52
+ * Returns only the base64-encoded key. For the DKG attestation
53
+ * bundle (which changes over time as peer quotes replicate via
54
+ * Raft), call `fetchDkgAttestation()` \u2014 that path is
55
+ * intentionally uncached.
37
56
  */
38
57
  export declare function fetchMlKemPublicKey(baseUrl?: string): Promise<string>;
58
+ /**
59
+ * Fetch the DKG attestation bundle from `${nodeUrl}/status`. Never
60
+ * cached \u2014 peer quotes are written to consensus KV asynchronously
61
+ * during cluster bootstrap, so early reads may see a subset of the
62
+ * expected quotes. Caching would pin an incomplete bundle and cause
63
+ * spurious `valid_count < expected_count` failures in
64
+ * `verifyDkgAttestation()` for the whole process lifetime.
65
+ *
66
+ * Returns `undefined` when the node has not yet published an
67
+ * attestation (e.g. still bootstrapping, or running with a mock
68
+ * signer where attestation is skipped by design).
69
+ */
70
+ export declare function fetchDkgAttestation(baseUrl?: string): Promise<DkgAttestation | undefined>;
39
71
  /** Clear the cached ML-KEM public keys. Useful in tests. */
40
72
  export declare function clearKeyCache(): void;
41
73
  /**
@@ -44,5 +76,7 @@ export declare function clearKeyCache(): void;
44
76
  * `fetchMlKemPublicKey()`.
45
77
  */
46
78
  export declare function loadConfig(baseUrl?: string): SdkConfig;
79
+ export { verifyTdxQuote, verifyDkgAttestation } from "../wasm/quote-verifier-loader";
80
+ export type { QuoteVerifyResult, DkgVerifyResult, PeerQuoteResult, } from "../wasm/quote-verifier-loader";
47
81
  export type { SdkConfig, Environment, ConfigValidationResult } from "./types";
48
82
  export { validateConfig } from "./loader";
@@ -19,5 +19,5 @@ export type { WasmComponent, ClientHandshake, ClientAuth, SessionCrypto, WasmNex
19
19
  export { loadWasmComponent } from "./wasm";
20
20
  export { generateRandomString, generateUUID, getScriptVersion, stringToBytes, bytesToString, redactSecrets, redactSecretsFromJson, } from "./utils";
21
21
  export { T3nError, SessionStateError, AuthenticationError, HandshakeError, RpcError, WasmError, decodeWasmErrorMessage, extractWasmError, } from "./utils/errors";
22
- export type { SdkConfig, Environment, ConfigValidationResult } from "./config";
23
- export { loadConfig, fetchMlKemPublicKey, clearKeyCache, getEnvironmentName, getEnvironment, setEnvironment, setNodeUrl, getNodeUrl, NODE_URLS, validateConfig, } from "./config";
22
+ export type { SdkConfig, Environment, ConfigValidationResult, DkgAttestation, QuoteVerifyResult, DkgVerifyResult, PeerQuoteResult, } from "./config";
23
+ export { loadConfig, fetchMlKemPublicKey, fetchDkgAttestation, verifyTdxQuote, verifyDkgAttestation, clearKeyCache, getEnvironmentName, getEnvironment, setEnvironment, setNodeUrl, getNodeUrl, NODE_URLS, validateConfig, } from "./config";
@@ -16,11 +16,16 @@ export interface EthereumSigner {
16
16
  signMessage(message: Uint8Array): Promise<Uint8Array>;
17
17
  }
18
18
  /**
19
- * OIDC credentials interface
19
+ * OIDC credentials interface.
20
+ *
21
+ * The TEE generates a session-binding nonce that must be included in
22
+ * the Google authorization URL (`&nonce=…`). The `getIdToken` callback
23
+ * receives this nonce and must return the `id_token` JWT obtained
24
+ * from the OIDC provider with the nonce baked into its claims.
20
25
  */
21
26
  export interface OidcCredentials {
22
27
  provider: string;
23
- idToken: string;
28
+ getIdToken: (nonce: string) => Promise<string>;
24
29
  }
25
30
  /**
26
31
  * Base authentication input with method discriminator