@terminal3/t3n-sdk 0.7.0 → 0.10.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 +266 -294
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/config.d.ts +30 -10
- package/dist/src/client/index.d.ts +0 -4
- package/dist/src/client/t3n-client.d.ts +27 -64
- package/dist/src/config/index.d.ts +36 -2
- package/dist/src/index.d.ts +9 -8
- package/dist/src/types/auth.d.ts +6 -5
- package/dist/src/types/index.d.ts +13 -37
- package/dist/src/utils/hkdf.d.ts +36 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/wasm/interface.d.ts +54 -89
- package/dist/src/wasm/loader.d.ts +55 -25
- 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/host-session-interfaces-contract-dispatch.d.ts +2 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-entropy.d.ts +2 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-eth-signer.d.ts +2 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-kem.d.ts +3 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-oidc-client.d.ts +2 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-oidc.d.ts +3 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-session-ops.d.ts +9 -0
- package/dist/wasm/generated/interfaces/host-session-interfaces-transport.d.ts +2 -0
- package/dist/wasm/generated/interfaces/tee-session-client-auth.d.ts +7 -0
- package/dist/wasm/generated/interfaces/tee-session-client-handshake.d.ts +12 -0
- package/dist/wasm/generated/interfaces/tee-session-cookie.d.ts +7 -0
- package/dist/wasm/generated/interfaces/tee-session-server-admin.d.ts +2 -0
- package/dist/wasm/generated/interfaces/tee-session-server-auth.d.ts +10 -0
- package/dist/wasm/generated/interfaces/tee-session-server-handshake.d.ts +15 -0
- package/dist/wasm/generated/interfaces/tee-session-server-webhook.d.ts +6 -0
- package/dist/wasm/generated/interfaces/tee-session-session-crypto.d.ts +3 -0
- package/dist/wasm/generated/session.core.wasm +0 -0
- package/dist/wasm/generated/session.core2.wasm +0 -0
- package/dist/wasm/generated/session.core3.wasm +0 -0
- package/dist/wasm/generated/session.d.ts +87 -12
- package/dist/wasm/generated/session.js +6640 -3702
- package/package.json +1 -1
- package/dist/demo.d.ts +0 -25
- package/dist/src/client/actions.d.ts +0 -22
- package/dist/src/client/encryption.d.ts +0 -30
- package/dist/src/client/handlers.d.ts +0 -73
- package/dist/src/client/request-parser.d.ts +0 -48
- package/dist/wasm/generated/interfaces/component-session-client-auth.d.ts +0 -12
- package/dist/wasm/generated/interfaces/component-session-client-handshake.d.ts +0 -12
- package/dist/wasm/generated/interfaces/component-session-cookie.d.ts +0 -8
- package/dist/wasm/generated/interfaces/component-session-server-auth.d.ts +0 -13
- package/dist/wasm/generated/interfaces/component-session-server-handshake.d.ts +0 -12
- package/dist/wasm/generated/interfaces/component-session-session.d.ts +0 -7
package/package.json
CHANGED
package/dist/demo.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* T3n SDK Real WASM Demo Script
|
|
3
|
-
*
|
|
4
|
-
* This script demonstrates the T3n SDK using the actual WASM component
|
|
5
|
-
* built from the node session module.
|
|
6
|
-
*/
|
|
7
|
-
import { SessionStatus, Did } from "./src/index";
|
|
8
|
-
import { type ChildProcess } from "child_process";
|
|
9
|
-
declare global {
|
|
10
|
-
var __oidcServerProcess: ChildProcess | undefined;
|
|
11
|
-
}
|
|
12
|
-
interface DemoResult {
|
|
13
|
-
sessionId: {
|
|
14
|
-
value: string;
|
|
15
|
-
};
|
|
16
|
-
status: SessionStatus;
|
|
17
|
-
wasmLoaded: boolean;
|
|
18
|
-
authenticated: boolean;
|
|
19
|
-
did: Did | null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Main Demo Function
|
|
23
|
-
*/
|
|
24
|
-
declare function runRealWasmDemo(): Promise<DemoResult>;
|
|
25
|
-
export { runRealWasmDemo, type DemoResult };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WASM Action Creators
|
|
3
|
-
*
|
|
4
|
-
* Creates the initial action payloads for WASM state machines.
|
|
5
|
-
* These are JSON-serialized and passed to the WASM component to start flows.
|
|
6
|
-
*/
|
|
7
|
-
import { AuthInput } from "../types";
|
|
8
|
-
/**
|
|
9
|
-
* Create the initial handshake request
|
|
10
|
-
* This kicks off the handshake state machine in WASM
|
|
11
|
-
*/
|
|
12
|
-
export declare function createHandshakeAction(): Uint8Array;
|
|
13
|
-
/**
|
|
14
|
-
* Create the initial authentication request based on auth method
|
|
15
|
-
* @param authInput - The authentication input (Ethereum or OIDC)
|
|
16
|
-
*/
|
|
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;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session Encryption Service
|
|
3
|
-
*
|
|
4
|
-
* Handles encryption and decryption of data using the established WASM session.
|
|
5
|
-
* Keeps cryptographic operations isolated and simple.
|
|
6
|
-
*/
|
|
7
|
-
import { SessionCrypto } from "../wasm";
|
|
8
|
-
import { Logger } from "../utils/logger";
|
|
9
|
-
/**
|
|
10
|
-
* Encrypts and decrypts data using an established session
|
|
11
|
-
*/
|
|
12
|
-
export declare class SessionEncryption {
|
|
13
|
-
private sessionCrypto;
|
|
14
|
-
private logger;
|
|
15
|
-
constructor(sessionCrypto: SessionCrypto, logger: Logger);
|
|
16
|
-
/**
|
|
17
|
-
* Encrypt data using the session
|
|
18
|
-
* @param sessionState - The session state bytes (from handshake)
|
|
19
|
-
* @param data - The plaintext data to encrypt
|
|
20
|
-
* @returns Base64-encoded encrypted data
|
|
21
|
-
*/
|
|
22
|
-
encrypt(sessionState: Uint8Array, data: Uint8Array): Promise<string>;
|
|
23
|
-
/**
|
|
24
|
-
* Decrypt data using the session
|
|
25
|
-
* @param sessionState - The session state bytes (from handshake)
|
|
26
|
-
* @param encryptedData - Base64-encoded encrypted data
|
|
27
|
-
* @returns Decrypted plaintext bytes
|
|
28
|
-
*/
|
|
29
|
-
decrypt(sessionState: Uint8Array, encryptedData: string): Promise<Uint8Array>;
|
|
30
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Guest-to-Host Request Handlers
|
|
3
|
-
*
|
|
4
|
-
* These handle requests from WASM that need the host environment to perform side effects.
|
|
5
|
-
* Examples: signing challenges, providing public keys, generating random bytes.
|
|
6
|
-
*/
|
|
7
|
-
import { GuestToHostHandler, GuestToHostHandlers } from "../types";
|
|
8
|
-
import { Logger } from "../utils/logger";
|
|
9
|
-
/**
|
|
10
|
-
* Account — MetaMask handler accepts either a plain address string or an
|
|
11
|
-
* object with an `address` field (for compatibility with various wallet
|
|
12
|
-
* libraries).
|
|
13
|
-
*/
|
|
14
|
-
type EthAccount = string | {
|
|
15
|
-
address: string;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Create an EthSign handler using MetaMask (window.ethereum)
|
|
19
|
-
* @param account - MetaMask account (string address or object with address property)
|
|
20
|
-
* @param logger - Optional logger instance. Defaults to a logger using the global log level (LogLevel.ERROR).
|
|
21
|
-
* Pass a custom logger to override logging behavior for this handler.
|
|
22
|
-
* @param privateKey - Optional private key for signing (if provided, MetaMask is not used)
|
|
23
|
-
*/
|
|
24
|
-
export declare function metamask_sign(account: EthAccount, logger?: Logger, privateKey?: string | undefined): GuestToHostHandler;
|
|
25
|
-
/**
|
|
26
|
-
* Get the current MetaMask address
|
|
27
|
-
* @returns Ethereum address (lowercase, 0x prefixed)
|
|
28
|
-
*/
|
|
29
|
-
export declare function metamask_get_address(): Promise<string>;
|
|
30
|
-
/**
|
|
31
|
-
* Get the address for a given private key
|
|
32
|
-
* @param privateKey - Ethereum private key (0x prefixed hex string)
|
|
33
|
-
* @returns Ethereum address (lowercase, 0x prefixed)
|
|
34
|
-
*/
|
|
35
|
-
export declare function eth_get_address(privateKey: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Create an MlKemPublicKey handler that lazily fetches the root public key
|
|
38
|
-
* from `${baseUrl}/status` on first invocation and caches the encoded
|
|
39
|
-
* response for subsequent calls.
|
|
40
|
-
*
|
|
41
|
-
* @param baseUrl - **Required**. The node URL whose `/status` endpoint should
|
|
42
|
-
* serve the ML-KEM public key. Must be the same URL the
|
|
43
|
-
* T3nClient is constructed with — otherwise the handshake
|
|
44
|
-
* encrypts to one node and sends ciphertext to another.
|
|
45
|
-
*
|
|
46
|
-
* Was optional in 0.3.x, where omitting it caused the lazy
|
|
47
|
-
* fetch to silently fall back to `NODE_URLS[currentEnv]` and
|
|
48
|
-
* hit the wrong node. Three downstream consumers (demo.ts,
|
|
49
|
-
* t3-apps dev wallet hooks, t3n-mcp session manager) all
|
|
50
|
-
* hit this trap before we tightened the type.
|
|
51
|
-
*/
|
|
52
|
-
export declare function createMlKemPublicKeyHandler(baseUrl: string): GuestToHostHandler;
|
|
53
|
-
/**
|
|
54
|
-
* Create Random handler backed by crypto.getRandomValues
|
|
55
|
-
* Note: The Rust Vec<u8> type serializes as an array of bytes, not a base64 string
|
|
56
|
-
*/
|
|
57
|
-
export declare function createRandomHandler(): GuestToHostHandler;
|
|
58
|
-
/**
|
|
59
|
-
* Create the default handler set required by the T3n handshake.
|
|
60
|
-
*
|
|
61
|
-
* @param baseUrl - **Required**. Forwarded to `createMlKemPublicKeyHandler`
|
|
62
|
-
* so the lazy /status fetch hits the right node.
|
|
63
|
-
*/
|
|
64
|
-
export declare function createDefaultHandlers(baseUrl: string): GuestToHostHandlers;
|
|
65
|
-
/**
|
|
66
|
-
* Merge consumer-provided handlers with defaults (user handlers take precedence).
|
|
67
|
-
*
|
|
68
|
-
* @param handlers - Optional consumer overrides.
|
|
69
|
-
* @param baseUrl - **Required**. Forwarded to the default handler set so the
|
|
70
|
-
* ML-KEM key fetch hits the right node.
|
|
71
|
-
*/
|
|
72
|
-
export declare function mergeWithDefaultHandlers(handlers: GuestToHostHandlers | undefined, baseUrl: string): GuestToHostHandlers;
|
|
73
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WASM Request Parser
|
|
3
|
-
*
|
|
4
|
-
* Parses and categorizes requests from the WASM state machine.
|
|
5
|
-
* The WASM component outputs JSON with a `guest_to_host` tag that determines
|
|
6
|
-
* how the SDK should handle the request.
|
|
7
|
-
*
|
|
8
|
-
* See node/session/src/abi.rs for the GuestToHost enum definition.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Types of requests that can come from WASM
|
|
12
|
-
*/
|
|
13
|
-
export declare enum WasmRequestType {
|
|
14
|
-
/** Send data to remote server (PeerReply with action) */
|
|
15
|
-
SendRemote = "SendRemote",
|
|
16
|
-
/** Request to host (SDK) for side effects (MlKemPublicKey, Random, EthSign, etc.) */
|
|
17
|
-
GuestToHost = "GuestToHost",
|
|
18
|
-
/** Flow complete (Suspend) */
|
|
19
|
-
Suspend = "Suspend"
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Parsed result from WASM request
|
|
23
|
-
*/
|
|
24
|
-
export interface ParsedRequest {
|
|
25
|
-
type: WasmRequestType;
|
|
26
|
-
data: Record<string, unknown>;
|
|
27
|
-
raw: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Parses WASM request bytes into a categorized request type
|
|
31
|
-
*/
|
|
32
|
-
export declare function parseWasmRequest(requestBytes: Uint8Array): ParsedRequest;
|
|
33
|
-
/**
|
|
34
|
-
* Check if a request should be sent to the remote server
|
|
35
|
-
*/
|
|
36
|
-
export declare function isSendRemote(parsed: ParsedRequest): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Check if a request indicates flow completion
|
|
39
|
-
*/
|
|
40
|
-
export declare function isCompletion(parsed: ParsedRequest): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Check if a request needs a guest-to-host handler
|
|
43
|
-
*/
|
|
44
|
-
export declare function isGuestToHost(parsed: ParsedRequest): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Get the guest-to-host request type name (e.g., "MlKemPublicKey", "Random", "EthSign")
|
|
47
|
-
*/
|
|
48
|
-
export declare function getGuestToHostType(parsed: ParsedRequest): string | null;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/client-auth@0.1.0 **/
|
|
2
|
-
export function next(state: State | undefined, action: HostToGuest): NewState;
|
|
3
|
-
export function finish(state: State): Did;
|
|
4
|
-
export type GuestToHost = Uint8Array;
|
|
5
|
-
export type State = Uint8Array;
|
|
6
|
-
export type HostToGuest = Uint8Array;
|
|
7
|
-
export type Did = Uint8Array;
|
|
8
|
-
export type Error = Uint8Array;
|
|
9
|
-
export interface NewState {
|
|
10
|
-
state: State,
|
|
11
|
-
request: GuestToHost,
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/client-handshake@0.1.0 **/
|
|
2
|
-
export function next(state: State | undefined, action: HostToGuest): NewState;
|
|
3
|
-
export function finish(state: State): SessionState;
|
|
4
|
-
export type GuestToHost = Uint8Array;
|
|
5
|
-
export type State = Uint8Array;
|
|
6
|
-
export type HostToGuest = Uint8Array;
|
|
7
|
-
export type SessionState = Uint8Array;
|
|
8
|
-
export type Error = Uint8Array;
|
|
9
|
-
export interface NewState {
|
|
10
|
-
state: State,
|
|
11
|
-
request: GuestToHost,
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/cookie@0.1.0 **/
|
|
2
|
-
export function validate(cookieValue: string, teeAddress: Uint8Array, nowSec: bigint): Validation;
|
|
3
|
-
export interface Validation {
|
|
4
|
-
authenticated: boolean,
|
|
5
|
-
did?: string,
|
|
6
|
-
exp: bigint,
|
|
7
|
-
}
|
|
8
|
-
export type Error = Uint8Array;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/server-auth@0.1.0 **/
|
|
2
|
-
export function next(state: State | undefined, action: HostToGuest, policy: SiwePolicy): NewState;
|
|
3
|
-
export function finish(state: State): Did;
|
|
4
|
-
export type GuestToHost = Uint8Array;
|
|
5
|
-
export type State = Uint8Array;
|
|
6
|
-
export type HostToGuest = Uint8Array;
|
|
7
|
-
export type SiwePolicy = Uint8Array;
|
|
8
|
-
export type Did = Uint8Array;
|
|
9
|
-
export type Error = Uint8Array;
|
|
10
|
-
export interface NewState {
|
|
11
|
-
state: State,
|
|
12
|
-
request: GuestToHost,
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/server-handshake@0.1.0 **/
|
|
2
|
-
export function next(state: State | undefined, action: HostToGuest): NewState;
|
|
3
|
-
export function finish(state: State): SessionState;
|
|
4
|
-
export type GuestToHost = Uint8Array;
|
|
5
|
-
export type State = Uint8Array;
|
|
6
|
-
export type HostToGuest = Uint8Array;
|
|
7
|
-
export type SessionState = Uint8Array;
|
|
8
|
-
export type Error = Uint8Array;
|
|
9
|
-
export interface NewState {
|
|
10
|
-
state: State,
|
|
11
|
-
request: GuestToHost,
|
|
12
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** @module Interface component:session/session@0.1.0 **/
|
|
2
|
-
export function encrypt(session: Session, plaintext: Plaintext): Ciphertext;
|
|
3
|
-
export function decrypt(session: Session, ciphertext: Ciphertext): Plaintext;
|
|
4
|
-
export type Error = Uint8Array;
|
|
5
|
-
export type Session = Uint8Array;
|
|
6
|
-
export type Plaintext = Uint8Array;
|
|
7
|
-
export type Ciphertext = Uint8Array;
|