@terminal3/t3n-sdk 3.2.0 → 3.4.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 (42) hide show
  1. package/README.md +33 -796
  2. package/dist/index.d.ts +288 -115
  3. package/dist/index.esm.js +1 -1
  4. package/dist/index.js +1 -1
  5. package/package.json +10 -60
  6. package/README.OIDC.md +0 -216
  7. package/dist/demo.d.ts +0 -25
  8. package/dist/src/client/actions.d.ts +0 -31
  9. package/dist/src/client/config.d.ts +0 -33
  10. package/dist/src/client/contract-response.d.ts +0 -59
  11. package/dist/src/client/delegation.d.ts +0 -388
  12. package/dist/src/client/encryption.d.ts +0 -30
  13. package/dist/src/client/handlers.d.ts +0 -73
  14. package/dist/src/client/index.d.ts +0 -13
  15. package/dist/src/client/org-data.d.ts +0 -269
  16. package/dist/src/client/request-parser.d.ts +0 -48
  17. package/dist/src/client/t3n-client.d.ts +0 -544
  18. package/dist/src/client/transport.d.ts +0 -131
  19. package/dist/src/config/index.d.ts +0 -82
  20. package/dist/src/config/loader.d.ts +0 -8
  21. package/dist/src/config/types.d.ts +0 -25
  22. package/dist/src/index.d.ts +0 -39
  23. package/dist/src/types/auth.d.ts +0 -66
  24. package/dist/src/types/index.d.ts +0 -45
  25. package/dist/src/types/kyc.d.ts +0 -135
  26. package/dist/src/types/org-data.d.ts +0 -180
  27. package/dist/src/types/session.d.ts +0 -24
  28. package/dist/src/types/token.d.ts +0 -102
  29. package/dist/src/types/user.d.ts +0 -236
  30. package/dist/src/utils/contract-version.d.ts +0 -5
  31. package/dist/src/utils/crypto.d.ts +0 -52
  32. package/dist/src/utils/errors.d.ts +0 -144
  33. package/dist/src/utils/index.d.ts +0 -10
  34. package/dist/src/utils/logger.d.ts +0 -102
  35. package/dist/src/utils/redaction.d.ts +0 -13
  36. package/dist/src/utils/session.d.ts +0 -37
  37. package/dist/src/utils/shape.d.ts +0 -30
  38. package/dist/src/wasm/index.d.ts +0 -5
  39. package/dist/src/wasm/interface.d.ts +0 -110
  40. package/dist/src/wasm/loader.d.ts +0 -43
  41. package/dist/src/wasm/quote-verifier/quote_verifier_bytes.d.ts +0 -1
  42. package/dist/src/wasm/quote-verifier-loader.d.ts +0 -58
@@ -1,37 +0,0 @@
1
- /**
2
- * Session validation utilities for T3n SDK
3
- */
4
- import { Logger } from "./logger";
5
- /**
6
- * Validation result for session bytes
7
- */
8
- export interface SessionValidationResult {
9
- /** Whether the session bytes are valid JSON */
10
- isValidJSON: boolean;
11
- /** Whether the parsed result is a string */
12
- isString: boolean;
13
- /** Whether the parsed result is a DID string */
14
- isDID: boolean;
15
- /** Whether the parsed result is an object with a 'secret' property */
16
- hasSecret: boolean;
17
- /** Type of the 'secret' property if it exists */
18
- secretType?: string;
19
- /** Whether the 'secret' is an array */
20
- secretIsArray?: boolean;
21
- /** Length of the 'secret' array if it's an array */
22
- secretLength?: number | string;
23
- /** Preview of the session text (first 100 chars) */
24
- sessionPreview?: string;
25
- /** Any error that occurred during validation */
26
- error?: string;
27
- }
28
- /**
29
- * Validate and analyze session bytes format
30
- * Handles both JSON objects and DID strings safely
31
- *
32
- * @param sessionBytes - The session bytes to validate
33
- * @param logger - Logger instance for debug/error output
34
- * @param context - Optional context for logging
35
- * @returns Validation result object
36
- */
37
- export declare function validateSessionBytes(sessionBytes: Uint8Array, logger: Logger, context?: string): SessionValidationResult;
@@ -1,30 +0,0 @@
1
- /**
2
- * Runtime shape guards for SDK response decoding.
3
- *
4
- * The contract layer is the source of truth for response shapes, but the
5
- * SDK's typed wrappers (`result as T`) are pure compile-time casts that
6
- * silently accept anything if a contract drifts or returns an unexpected
7
- * payload past the heuristic refusal-string check. `assertShape` lets the
8
- * outermost SDK boundary throw a deterministic, named error at the call
9
- * site rather than letting callers reach for `.admins` on `undefined`
10
- * deep in their own code.
11
- *
12
- * Predicates are intentionally shallow — they validate the immediate
13
- * top-level structure (object kind, presence/type of leading fields)
14
- * but do not deeply validate nested elements (e.g. each `UserGrant`
15
- * inside `OrgContractGrants.grants`). Deep validation would be brittle
16
- * against benign contract additions; shallow guards catch the failure
17
- * modes that actually surface as runtime crashes (null/string/missing
18
- * top-level field).
19
- */
20
- /** Narrowing helper: value is a non-null object record. */
21
- export declare function isObject(value: unknown): value is Record<string, unknown>;
22
- /**
23
- * Run a type-predicate guard against `value` and throw a named error if
24
- * it fails. Returns the value typed as `T` on success.
25
- *
26
- * @param where - call-site identifier included in the thrown error
27
- * message (e.g. `'org-policy-get'`) so operators can grep logs back
28
- * to the offending RPC.
29
- */
30
- export declare function assertShape<T>(value: unknown, guard: (v: unknown) => v is T, where: string): T;
@@ -1,5 +0,0 @@
1
- /**
2
- * WASM integration exports for T3n SDK
3
- */
4
- export * from "./interface";
5
- export * from "./loader";
@@ -1,110 +0,0 @@
1
- /**
2
- * WASM Component Interface - Mirrors the WIT specification exactly
3
- *
4
- * This interface works with completely opaque byte arrays, just like the WIT interface.
5
- * The TypeScript SDK doesn't know about internal state machine phases or details.
6
- */
7
- /**
8
- * Result type for WASM next() operations
9
- */
10
- export interface WasmNextResult {
11
- state: Uint8Array;
12
- request: Uint8Array;
13
- }
14
- /**
15
- * Client handshake operations - completely opaque byte arrays only
16
- */
17
- export interface ClientHandshake {
18
- /**
19
- * Process next step in handshake
20
- * @param state - Current handshake state (null for initial call)
21
- * @param action - Action to process (opaque bytes)
22
- * @returns Promise with new state and request to send
23
- */
24
- next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
25
- /**
26
- * Attempt to finalize handshake
27
- * @param state - Current handshake state
28
- * @returns Promise with session bytes if successful
29
- * @throws Error containing "not yet finalized" if the state machine
30
- * has not reached its terminal phase. The SDK runtime treats
31
- * this as the loop's "keep going" signal, not a real error.
32
- */
33
- finish(state: Uint8Array): Promise<Uint8Array>;
34
- }
35
- /**
36
- * Client authentication operations - completely opaque byte arrays only
37
- */
38
- export interface ClientAuth {
39
- /**
40
- * Process next step in authentication
41
- * @param state - Current auth state (null for initial call)
42
- * @param action - Action to process (opaque bytes)
43
- * @returns Promise with new state and request to send
44
- */
45
- next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
46
- /**
47
- * Attempt to finalize authentication
48
- * @param state - Current auth state
49
- * @returns Promise with DID bytes if successful
50
- * @throws Error containing "not yet finalized" if the state machine
51
- * has not reached its terminal phase. The SDK runtime treats
52
- * this as the loop's "keep going" signal, not a real error.
53
- */
54
- finish(state: Uint8Array): Promise<Uint8Array>;
55
- }
56
- /**
57
- * Client authentication operations - completely opaque byte arrays only
58
- */
59
- export interface ClientExecute {
60
- /**
61
- * Process next step in authentication
62
- * @param state - Current auth state (null for initial call)
63
- * @param action - Action to process (opaque bytes)
64
- * @returns Promise with new state and request to send
65
- */
66
- next(state: Uint8Array | null, action: Uint8Array): Promise<WasmNextResult>;
67
- /**
68
- * Attempt to finalize authentication
69
- * @param state - Current auth state
70
- * @returns Promise with DID bytes if successful
71
- * @throws Error containing "not yet finalized" if the state machine
72
- * has not reached its terminal phase. The SDK runtime treats
73
- * this as the loop's "keep going" signal, not a real error.
74
- */
75
- finish(state: Uint8Array): Promise<Uint8Array>;
76
- }
77
- /**
78
- * Session encryption/decryption operations - completely opaque byte arrays only
79
- */
80
- export interface SessionCrypto {
81
- /**
82
- * Encrypt plaintext using session
83
- * @param session - Session state (opaque bytes)
84
- * @param plaintext - Data to encrypt
85
- * @returns Promise with encrypted bytes
86
- */
87
- encrypt(session: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
88
- /**
89
- * Decrypt ciphertext using session
90
- * @param session - Session state (opaque bytes)
91
- * @param ciphertext - Data to decrypt
92
- * @returns Promise with decrypted bytes
93
- */
94
- decrypt(session: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
95
- }
96
- /**
97
- * Main WASM Component interface - mirrors the WIT interface exactly
98
- *
99
- * This is completely opaque to the TypeScript layer. All state machine logic,
100
- * authentication flows, and cryptographic operations are handled in WASM.
101
- */
102
- export interface WasmComponent {
103
- /** Client-side state machines exported by the WASM component. */
104
- flow: {
105
- handshake: ClientHandshake;
106
- auth: ClientAuth;
107
- execute: ClientExecute;
108
- };
109
- session: SessionCrypto;
110
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * WASM Component Loader
3
- *
4
- * This module provides utilities for loading and initializing the WASM component.
5
- * The actual WASM loading implementation will depend on the build system and
6
- * deployment environment.
7
- */
8
- import { WasmComponent } from "./interface";
9
- import { Logger } from "../utils/logger";
10
- /**
11
- * Configuration for WASM component loading
12
- */
13
- export interface WasmLoadConfig {
14
- /** Path or URL to the WASM module */
15
- wasmPath?: string;
16
- /** Custom fetch function for loading WASM */
17
- fetchFn?: typeof fetch;
18
- /** Additional initialization options */
19
- initOptions?: Record<string, unknown>;
20
- /** Optional logger instance - if not provided, uses global default */
21
- logger?: Logger;
22
- }
23
- /**
24
- * Load and initialize the T3n WASM component
25
- *
26
- * @param config - Optional configuration for loading the WASM component
27
- * @returns Promise that resolves to the initialized WASM component
28
- *
29
- * @example
30
- * ```typescript
31
- * const wasmComponent = await loadWasmComponent({
32
- * wasmPath: '/path/to/t3n.wasm'
33
- * });
34
- * ```
35
- */
36
- export declare function loadWasmComponent(config?: WasmLoadConfig): Promise<WasmComponent>;
37
- /**
38
- * Load the real T3n WASM component
39
- *
40
- * @param logger - Logger instance for WASM operations
41
- * @returns Promise that resolves to the initialized WASM component
42
- */
43
- export declare function loadRealWasmComponent(logger: Logger): Promise<WasmComponent>;