@terminal3/t3n-sdk 0.10.0 → 0.11.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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/demo.d.ts +25 -0
  3. package/dist/index.d.ts +347 -172
  4. package/dist/index.esm.js +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/src/client/actions.d.ts +22 -0
  7. package/dist/src/client/config.d.ts +10 -30
  8. package/dist/src/client/encryption.d.ts +30 -0
  9. package/dist/src/client/handlers.d.ts +73 -0
  10. package/dist/src/client/index.d.ts +4 -0
  11. package/dist/src/client/request-parser.d.ts +48 -0
  12. package/dist/src/client/t3n-client.d.ts +113 -26
  13. package/dist/src/index.d.ts +6 -7
  14. package/dist/src/types/auth.d.ts +5 -6
  15. package/dist/src/types/index.d.ts +37 -13
  16. package/dist/src/utils/index.d.ts +0 -1
  17. package/dist/src/wasm/interface.d.ts +95 -54
  18. package/dist/src/wasm/loader.d.ts +25 -55
  19. package/dist/wasm/generated/interfaces/component-session-client-auth.d.ts +12 -0
  20. package/dist/wasm/generated/interfaces/component-session-client-handshake.d.ts +12 -0
  21. package/dist/wasm/generated/interfaces/component-session-cookie.d.ts +8 -0
  22. package/dist/wasm/generated/interfaces/component-session-session.d.ts +7 -0
  23. package/dist/wasm/generated/session.core.wasm +0 -0
  24. package/dist/wasm/generated/session.d.ts +10 -87
  25. package/dist/wasm/generated/session.js +3254 -6713
  26. package/package.json +1 -1
  27. package/dist/src/utils/hkdf.d.ts +0 -36
  28. package/dist/wasm/generated/interfaces/host-session-interfaces-contract-dispatch.d.ts +0 -2
  29. package/dist/wasm/generated/interfaces/host-session-interfaces-entropy.d.ts +0 -2
  30. package/dist/wasm/generated/interfaces/host-session-interfaces-eth-signer.d.ts +0 -2
  31. package/dist/wasm/generated/interfaces/host-session-interfaces-kem.d.ts +0 -3
  32. package/dist/wasm/generated/interfaces/host-session-interfaces-oidc-client.d.ts +0 -2
  33. package/dist/wasm/generated/interfaces/host-session-interfaces-oidc.d.ts +0 -3
  34. package/dist/wasm/generated/interfaces/host-session-interfaces-session-ops.d.ts +0 -9
  35. package/dist/wasm/generated/interfaces/host-session-interfaces-transport.d.ts +0 -2
  36. package/dist/wasm/generated/interfaces/tee-session-client-auth.d.ts +0 -7
  37. package/dist/wasm/generated/interfaces/tee-session-client-handshake.d.ts +0 -12
  38. package/dist/wasm/generated/interfaces/tee-session-cookie.d.ts +0 -7
  39. package/dist/wasm/generated/interfaces/tee-session-server-admin.d.ts +0 -2
  40. package/dist/wasm/generated/interfaces/tee-session-server-auth.d.ts +0 -10
  41. package/dist/wasm/generated/interfaces/tee-session-server-handshake.d.ts +0 -15
  42. package/dist/wasm/generated/interfaces/tee-session-server-webhook.d.ts +0 -6
  43. package/dist/wasm/generated/interfaces/tee-session-session-crypto.d.ts +0 -3
  44. package/dist/wasm/generated/session.core2.wasm +0 -0
  45. package/dist/wasm/generated/session.core3.wasm +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terminal3/t3n-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "description": "T3n TypeScript SDK - A minimal SDK that mirrors the server's RPC handler approach",
6
6
  "main": "dist/index.js",
@@ -1,36 +0,0 @@
1
- /**
2
- * HKDF-SHA256 key derivation that mirrors `session::session::derive_keys`
3
- * in the node (`node/session/src/session.rs`).
4
- *
5
- * The server derives two directional keys from the raw ML-KEM shared
6
- * secret using HKDF-Extract-then-Expand with:
7
- * - salt = b"" (empty)
8
- * - ikm = the 32-byte raw KEM shared secret
9
- * - info = b"t3-session-v1-c2s" | b"t3-session-v1-s2c"
10
- * - L = 32 bytes each
11
- *
12
- * The client must derive the same pair so that c2s / s2c line up on
13
- * both sides. WebCrypto's `subtle.deriveBits` with `HKDF` does
14
- * Extract+Expand in one call, so the TS implementation collapses to a
15
- * few lines per direction.
16
- */
17
- /**
18
- * Derive directional session keys from the raw ML-KEM shared secret.
19
- *
20
- * @param rawSecret 32 bytes from `handshakeAsync.clientRun` (the
21
- * `ClientPending.secret` field).
22
- * @returns `{ c2s, s2c }` — each 32 bytes, suitable for AES-256-GCM.
23
- */
24
- export declare function deriveDirectionalKeys(rawSecret: Uint8Array): Promise<{
25
- c2s: Uint8Array;
26
- s2c: Uint8Array;
27
- }>;
28
- /**
29
- * Pack directional keys for the client-side session-crypto WASM calls.
30
- *
31
- * The contract's `session-crypto.encrypt`/`decrypt` interprets its
32
- * `keys` argument as `encrypt_key || decrypt_key`. The client
33
- * encrypts with c2s and decrypts with s2c, so the client packs
34
- * `c2s || s2c`.
35
- */
36
- export declare function packClientSessionKeys(c2s: Uint8Array, s2c: Uint8Array): Uint8Array;
@@ -1,2 +0,0 @@
1
- /** @module Interface host:session-interfaces/contract-dispatch@1.0.0 **/
2
- export function executeAction(contract: string, version: string, functionName: string, did: string, payload: Uint8Array): Uint8Array;
@@ -1,2 +0,0 @@
1
- /** @module Interface host:session-interfaces/entropy@1.0.0 **/
2
- export function random(len: number): Uint8Array;
@@ -1,2 +0,0 @@
1
- /** @module Interface host:session-interfaces/eth-signer@1.0.0 **/
2
- export function ethSign(message: Uint8Array): Uint8Array;
@@ -1,3 +0,0 @@
1
- /** @module Interface host:session-interfaces/kem@1.0.0 **/
2
- export function mlKemPublicKey(): Uint8Array;
3
- export function decapsulate(ciphertext: Uint8Array): Uint8Array;
@@ -1,2 +0,0 @@
1
- /** @module Interface host:session-interfaces/oidc-client@1.0.0 **/
2
- export function getIdToken(provider: string, nonce: string): string;
@@ -1,3 +0,0 @@
1
- /** @module Interface host:session-interfaces/oidc@1.0.0 **/
2
- export function fetchJwks(jwksUri: string): Uint8Array;
3
- export function fetchClientId(providerName: string): string;
@@ -1,9 +0,0 @@
1
- /** @module Interface host:session-interfaces/session-ops@1.0.0 **/
2
- export function nowMs(): bigint;
3
- export function teeAddress(): Uint8Array;
4
- export function fetchOrCreateDid(authenticatorHashes: Array<Uint8Array>, did: string | undefined): string;
5
- export function fetchProviderConfig(providerId: string): Uint8Array;
6
- export function setCookie(cookieValue: string): void;
7
- export function registerScript(name: string, version: string, wasmBytes: Uint8Array, sourceHash: string | undefined): boolean;
8
- export function syncUserAuths(): Uint8Array;
9
- export function updateMeasurements(measurementsBase64: string): boolean;
@@ -1,2 +0,0 @@
1
- /** @module Interface host:session-interfaces/transport@1.0.0 **/
2
- export function postRpc(method: string, sessionId: string, params: string): string;
@@ -1,7 +0,0 @@
1
- /** @module Interface tee:session/client-auth@1.0.0 **/
2
- export function runEth(sessionKeys: Uint8Array, ethAddress: string, siweDomain: string | undefined, siweUrl: string | undefined, siweChainId: bigint | undefined): Outcome;
3
- export function runOidc(sessionKeys: Uint8Array, provider: string): Outcome;
4
- export interface Outcome {
5
- did: string,
6
- cookie?: string,
7
- }
@@ -1,12 +0,0 @@
1
- /** @module Interface tee:session/client-handshake@1.0.0 **/
2
- export function run(sid: Uint8Array, cookie: string | undefined): Outcome;
3
- export interface SessionKeys {
4
- blob: Uint8Array,
5
- sid: Uint8Array,
6
- }
7
- export interface Outcome {
8
- keys: SessionKeys,
9
- authenticated: boolean,
10
- did?: string,
11
- expirySec: bigint,
12
- }
@@ -1,7 +0,0 @@
1
- /** @module Interface tee:session/cookie@1.0.0 **/
2
- export function validate(value: string, teeAddress: Uint8Array, nowSec: bigint): Validation;
3
- export interface Validation {
4
- authenticated: boolean,
5
- did?: string,
6
- exp: bigint,
7
- }
@@ -1,2 +0,0 @@
1
- /** @module Interface tee:session/server-admin@1.0.0 **/
2
- export function run(headers: Array<[string, string]>, body: Uint8Array): Uint8Array;
@@ -1,10 +0,0 @@
1
- /** @module Interface tee:session/server-auth@1.0.0 **/
2
- export function run(persistedStateBytes: Uint8Array | undefined, initialActionJson: Uint8Array, siwePolicyJson: Uint8Array): Outcome;
3
- export interface Outcome {
4
- responseJson: Uint8Array,
5
- stateBytes?: Uint8Array,
6
- cookie?: string,
7
- did?: string,
8
- authenticatorsJson?: Uint8Array,
9
- finalized: boolean,
10
- }
@@ -1,15 +0,0 @@
1
- /** @module Interface tee:session/server-handshake@1.0.0 **/
2
- export function run(sid: Uint8Array, ciphertext: Uint8Array, cookieValue: string | undefined): Outcome;
3
- export interface SessionKeys {
4
- c2s: Uint8Array,
5
- s2c: Uint8Array,
6
- sid: Uint8Array,
7
- }
8
- export interface Outcome {
9
- keys: SessionKeys,
10
- rawSecret: Uint8Array,
11
- authenticated: boolean,
12
- did?: string,
13
- expirySec: bigint,
14
- refreshedCookie?: string,
15
- }
@@ -1,6 +0,0 @@
1
- /** @module Interface tee:session/server-webhook@1.0.0 **/
2
- export function run(providerId: string, headers: Array<[string, string]>, body: Uint8Array): Outcome;
3
- export interface Outcome {
4
- replyJson: Uint8Array,
5
- finalStateBytes: Uint8Array,
6
- }
@@ -1,3 +0,0 @@
1
- /** @module Interface tee:session/session-crypto@1.0.0 **/
2
- export function encrypt(keys: Uint8Array, plaintext: Uint8Array): Uint8Array;
3
- export function decrypt(keys: Uint8Array, ciphertext: Uint8Array): Uint8Array;