@terminal3/t3n-sdk 3.3.0 → 3.4.1

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 +281 -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 -276
  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,102 +0,0 @@
1
- /**
2
- * Token-metering types — T3-TS-030 wire shapes.
3
- *
4
- * Mirrors `node/primitives/src/token.rs`. `u128` fields land on the
5
- * wire as JSON numbers (same convention as the existing
6
- * `token.get-balance` response) — JS clients with histories that
7
- * exceed 2⁵³ tokens should switch to a streaming JSON parser; the
8
- * common case fits in `number` losslessly.
9
- */
10
- /**
11
- * `primitives::token::BalanceRow` — caller's credit row.
12
- *
13
- * `available` and `reserved` are `u128` on the server; the wire
14
- * format is a JSON number. Callers should not assume bigint until
15
- * the SDK migrates to a streaming parser (tracked separately).
16
- */
17
- export interface BalanceRow {
18
- available: number;
19
- reserved: number;
20
- last_settled_seq_no: number;
21
- version: number;
22
- credit_exhausted: boolean;
23
- }
24
- /**
25
- * `primitives::token::TokenTxKind` snake_case wire alphabet. Every
26
- * value listed here is accepted by the server-side
27
- * `token.get-usage` `kinds` filter.
28
- */
29
- export type TokenTxKind = "mint" | "burn" | "charge" | "transfer" | "bridge_mint_attest" | "bridge_burn_attest";
30
- /**
31
- * Per-caller view direction. `"in"` = caller's balance went up;
32
- * `"out"` = caller's balance went down. Derived host-side from
33
- * `(caller_did, tx.src, tx.dst)`; the same `seq_no` appears in both
34
- * parties' usage feeds with opposite directions on a transfer.
35
- */
36
- export type Direction = "in" | "out";
37
- /**
38
- * Discriminated union mirroring `primitives::token::ChargeReason`.
39
- * Present only when the row's `kind === "charge"`.
40
- */
41
- export type ChargeReason = {
42
- kind: "contract_register";
43
- script_name: string;
44
- version: string;
45
- } | {
46
- kind: "invocation";
47
- script_name: string;
48
- function: string;
49
- fuel_consumed: number;
50
- fuel_tokens: number;
51
- host_call_count: number;
52
- host_call_tokens: number;
53
- } | {
54
- kind: "kv_bytes";
55
- map: string;
56
- } | {
57
- kind: "cas_bytes";
58
- backend: string;
59
- } | {
60
- kind: "outbox_egress";
61
- upstream: string;
62
- };
63
- /**
64
- * One row in the caller's usage feed — a per-caller projection of
65
- * the underlying `TokenTx`. `counterparty` is the other party from
66
- * the caller's perspective: `tx.dst` on outbound entries, `tx.src`
67
- * on inbound. `null` when the underlying tx has no counterparty
68
- * (mints have no `src`; burns and charges have no `dst`).
69
- */
70
- export interface UsageEntry {
71
- seq_no: number;
72
- kind: TokenTxKind;
73
- amount: number;
74
- timestamp_ms: number;
75
- direction: Direction;
76
- counterparty?: string | null;
77
- reason?: ChargeReason | null;
78
- note?: string | null;
79
- }
80
- /**
81
- * Response shape of `token.get-usage` — caller's balance plus a
82
- * paginated slice of their most-recent `token:tx_log` entries.
83
- *
84
- * `next_cursor` is the inclusive upper-bound `seq_no` to pass back
85
- * as `after_seq` to fetch the next page. `null` (or absent) means
86
- * the caller's history is fully drained.
87
- */
88
- export interface UsagePage {
89
- balance: BalanceRow;
90
- entries: UsageEntry[];
91
- next_cursor?: number | null;
92
- }
93
- /**
94
- * Request shape — all fields optional. `limit` clamps to
95
- * `1..=200` server-side; out-of-range values snap silently to the
96
- * bounds. `kinds: []` is treated as "no filter".
97
- */
98
- export interface GetUsageOptions {
99
- limit?: number;
100
- after_seq?: number;
101
- kinds?: TokenTxKind[];
102
- }
@@ -1,236 +0,0 @@
1
- /**
2
- * MAT-1374 — wire types for the explicit `otp-request` /
3
- * `otp-verify` / slim `user-upsert` exports on `tee:user/contracts`
4
- * (`tee:user@2.0.0`).
5
- *
6
- * Pre-2.0.0 the user contract dispatched OTP request and OTP verify
7
- * implicitly from the input shape of a single `user-upsert` call.
8
- * 2.0.0 splits that surface into three explicit functions; the
9
- * shapes here mirror the Rust types in
10
- * `node/tee_contracts/user/src/otp_types.rs` and
11
- * `node/tee_contracts/user/src/upsert_types.rs`.
12
- *
13
- * Keep the two in sync — bytes flow directly from the contract
14
- * through the JSON-RPC envelope into the SDK wrappers
15
- * (`T3nClient.otpRequest`, `T3nClient.otpVerify`,
16
- * `T3nClient.submitUserInput`).
17
- */
18
- import { T3nError } from "../utils/errors";
19
- /**
20
- * OTP delivery channel. Matches the `OtpContactChannel` Rust enum
21
- * with `serde(rename_all = "snake_case")`.
22
- */
23
- export type OtpChannel = "email" | "sms";
24
- /**
25
- * Discriminated OTP contact target. Mirrors the Rust `OtpRequest` enum
26
- * (`email_channel` / `sms_channel` on the wire). Exactly one branch is
27
- * set — no parallel optional email + phone with a separate channel tag.
28
- *
29
- * The legacy `keys.generic_api.otp_channel` body shadow was removed
30
- * in 2.0.0 — the contract rejects calls carrying it with a
31
- * `legacy_field` error.
32
- */
33
- export type OtpRequestInput = {
34
- emailChannel: {
35
- emailAddress: string;
36
- };
37
- } | {
38
- smsChannel: {
39
- phoneNumber: string;
40
- };
41
- };
42
- /**
43
- * Response returned by `otp-request`. Mirrors `OtpResponse` in
44
- * `otp_types.rs`.
45
- *
46
- * - `contact` echoes the OTP destination so clients that race
47
- * multiple channels can correlate replies.
48
- * - `expiresAtSec` is the Unix-second TTL the host minted for the
49
- * pending OTP. Absent in `skip_otp` test environments.
50
- * - `status` is `"otp_pending"` on the happy path. `"otp_failed"`
51
- * only appears on retry without a fresh request — usually you
52
- * shouldn't see it on `otp-request`.
53
- * - `txHash` is the host-enriched ledger ref for the OTP-pending
54
- * write (the contract leaves it `null`; the host injects).
55
- * - `isNewProfile` is `true` on a fresh DID's first OTP request —
56
- * read this to detect "did the user just register".
57
- */
58
- export interface OtpRequestResult {
59
- contact: string;
60
- channel: OtpChannel;
61
- expiresAtSec?: number;
62
- status?: string;
63
- txHash?: string;
64
- isNewProfile?: boolean;
65
- }
66
- /**
67
- * Input to `T3nClient.otpVerify`. `otpCode` is mandatory; `request`
68
- * repeats the same discriminated contact shape as {@link OtpRequestInput}.
69
- */
70
- export interface OtpVerifyInput {
71
- otpCode: string;
72
- request: OtpRequestInput;
73
- }
74
- /**
75
- * Suggestion surfaced when the bind-target contact already belongs
76
- * to another DID. The contract refuses to silently steal the
77
- * authenticator; the caller must resolve the merge (typically via
78
- * `merge-profiles`) before re-attempting verify.
79
- */
80
- export interface OtpMergeSuggestion {
81
- existingDid: string;
82
- currentDid: string;
83
- email?: string;
84
- phone?: string;
85
- channel: OtpChannel;
86
- }
87
- /**
88
- * Response returned by `otp-verify`. Mirrors
89
- * `OtpVerifyResponse` in `otp_types.rs`.
90
- *
91
- * - `email` is populated on `channel = "email"` success;
92
- * `phone` on `channel = "sms"` success. Mutually exclusive on
93
- * the happy path.
94
- * - `status` carries `"otp_failed"` / `"otp_expired"` on retry; the
95
- * happy path leaves it `undefined`.
96
- * - `mergeSuggestion` is set when the contact-to-bind is already
97
- * owned by another DID. Wire it into your merge UX.
98
- */
99
- export interface OtpVerifyResult {
100
- txHash?: string;
101
- did: string;
102
- channel: OtpChannel;
103
- email?: string;
104
- phone?: string;
105
- status?: string;
106
- mergeSuggestion?: OtpMergeSuggestion;
107
- isNewProfile?: boolean;
108
- }
109
- /**
110
- * Level-1 user-input fields accepted by the slim `user-upsert`.
111
- * The Rust contract validates these via `validate_profile`; the
112
- * shape is intentionally open so callers can add provider-specific
113
- * fields on top of the canonical six.
114
- */
115
- export interface UserInputProfile {
116
- firstName?: string;
117
- lastName?: string;
118
- email_address?: string;
119
- phone_number?: string;
120
- birthdate?: string;
121
- nationality?: string;
122
- campaign_code?: string;
123
- role?: string;
124
- [key: string]: unknown;
125
- }
126
- /**
127
- * Input to `T3nClient.submitUserInput`. Maps onto the slim
128
- * `user-upsert` request shape: `{ profile, organisation_did?,
129
- * attestations?, keys? }`.
130
- */
131
- export interface SubmitUserInputArgs {
132
- profile: UserInputProfile;
133
- organisationDid?: string;
134
- attestations?: unknown;
135
- keys?: Record<string, unknown>;
136
- /**
137
- * KYC webhook orphan-attestation flow. When set, the contract
138
- * skips the email-not-verified gate and only records the
139
- * attestation if the DID has no profile yet (T3-TS-026 §13).
140
- * Most callers should leave this `undefined`.
141
- */
142
- requireExistingUser?: boolean;
143
- /**
144
- * MAT-1618 testnet self-admit. When `true`, the contract additionally
145
- * runs the self-admit side-effect after the profile commit: writes
146
- * the caller's DID into `idx:_tenants` + `idx:_tenant_quotas` and
147
- * mints any operator-configured welcome credits. Inspect the
148
- * `tenantAdmit` field on the response for the outcome.
149
- *
150
- * Testnet-only. Production clusters return
151
- * `tenantAdmit.status = "refused"` with
152
- * `reason = "not_testnet" | "self_admit_disabled" | "not_eth_derived"`.
153
- * The profile commit always succeeds regardless of the inner outcome.
154
- *
155
- * Most callers should leave this `undefined`.
156
- */
157
- becomeDevTenant?: boolean;
158
- }
159
- /**
160
- * MAT-1618 self-admit projection from `user-upsert`. Present only
161
- * when the caller set `becomeDevTenant: true` on the request.
162
- *
163
- * - `status: "admitted"` — first call for this DID; tenant record
164
- * committed and (if configured) welcome credits minted into
165
- * `grantedCredits`.
166
- * - `status: "already-admitted"` — replay; idempotent no-op.
167
- * - `status: "refused"` — the cluster declined the self-admit;
168
- * `reason` is the machine-readable cause (`not_testnet`,
169
- * `self_admit_disabled`, `not_eth_derived`), `detail` is a
170
- * human-readable string.
171
- */
172
- export type TenantAdmitStatus = "admitted" | "already-admitted" | "refused";
173
- export interface TenantAdmitProjection {
174
- status: TenantAdmitStatus;
175
- grantedCredits?: string;
176
- reason?: string;
177
- detail?: string;
178
- }
179
- /**
180
- * Response shape returned by the slim `user-upsert`. Carries the
181
- * post-merge tx hash plus the L1 merge diagnostics
182
- * (`refusedFields`, `mergeSuggestion`) the pre-2.0.0 omnibus
183
- * `UpsertResponse` already surfaced.
184
- */
185
- export interface SubmitUserInputResult {
186
- txHash?: string;
187
- refusedFields?: string[];
188
- mergeSuggestion?: OtpMergeSuggestion;
189
- userFound?: boolean;
190
- /**
191
- * MAT-1618 self-admit projection. Present only when the caller
192
- * set `becomeDevTenant: true` on the request.
193
- */
194
- tenantAdmit?: TenantAdmitProjection;
195
- }
196
- /**
197
- * Discriminator for {@link UserUpsertError}. Mirrors the
198
- * `UserUpsertError` Rust enum and its `<code>:<detail>` wire
199
- * format (see `upsert_types.rs::UserUpsertError::code`). Branch
200
- * with a `switch` over `kind`.
201
- *
202
- * - `EmailNotVerified` — the slim `user-upsert` was called against
203
- * a DID that has no verified email and no proving authenticator.
204
- * Run `otpRequest` + `otpVerify` first (or accept an
205
- * OIDC/Email-authed session).
206
- * - `LegacyField` — caller passed a pre-2.0.0 dispatch field
207
- * (`otp_code` to a non-verify export, or
208
- * `keys.generic_api.otp_channel` anywhere). Migrate the call
209
- * site to the new explicit functions.
210
- * - `UserNotFound` — `requireExistingUser` was set but no profile
211
- * exists for the DID. The attestation is recorded for audit;
212
- * no profile created.
213
- */
214
- export type UserUpsertErrorKind = "EmailNotVerified" | "LegacyField" | "UserNotFound";
215
- /**
216
- * Typed wrapper for the `<code>:<detail>` errors the slim
217
- * `user-upsert` and the OTP entry points emit. `kind` is the
218
- * structured discriminator the SDK derives from the error code
219
- * prefix; `code` and `detail` retain the wire components for
220
- * fall-through logging.
221
- *
222
- * Throw site: `T3nClient.submitUserInput` (and friends) when the
223
- * contract returns a string error matching the
224
- * `<code>:<detail>` shape.
225
- */
226
- export declare class UserUpsertError extends T3nError {
227
- readonly kind: UserUpsertErrorKind | "Unknown";
228
- readonly detail: string;
229
- constructor(code: string, detail: string);
230
- /**
231
- * Try to parse a contract error string into a `UserUpsertError`.
232
- * Returns `null` if `raw` doesn't match the `<code>:<detail>`
233
- * shape — caller falls back to a generic error.
234
- */
235
- static fromWire(raw: string): UserUpsertError | null;
236
- }
@@ -1,5 +0,0 @@
1
- export interface CurrentVersionResponse {
2
- current_version: string;
3
- }
4
- export declare function getScriptVersion(rpcUrl: string, scriptName: string): Promise<string>;
5
- export declare function resetScriptVersionCacheForTests(): void;
@@ -1,52 +0,0 @@
1
- /**
2
- * Cryptographic utilities for T3n SDK
3
- *
4
- * Cross-platform crypto support:
5
- * - Browsers: Uses Web Crypto API (global crypto)
6
- * - Node.js 19+: Uses global crypto
7
- * - Node.js 16-18: Imports crypto module
8
- */
9
- /**
10
- * Generate a cryptographically secure random string
11
- * @param length - Length of the random string in bytes
12
- * @returns Base64-encoded random string
13
- */
14
- export declare function generateRandomString(length?: number): string;
15
- /**
16
- * Generate a UUID v4
17
- * @returns UUID string
18
- */
19
- export declare function generateUUID(): string;
20
- /**
21
- * Fill an array with cryptographically secure random values
22
- * Cross-platform wrapper for crypto.getRandomValues
23
- * @param array - Array to fill with random values
24
- * @returns The same array (for compatibility with Web Crypto API)
25
- */
26
- export declare function getRandomValues(array: Uint8Array): Uint8Array;
27
- /**
28
- * Convert a string to Uint8Array
29
- * @param str - String to convert
30
- * @returns Uint8Array representation
31
- */
32
- export declare function stringToBytes(str: string): Uint8Array;
33
- /**
34
- * Convert Uint8Array to string
35
- * @param bytes - Bytes to convert
36
- * @returns String representation
37
- */
38
- export declare function bytesToString(bytes: Uint8Array): string;
39
- export declare function bytesToBase64(bytes: Uint8Array): string;
40
- export declare function base64ToBytes(base64: string): Uint8Array;
41
- /**
42
- * Sign raw bytes using EIP-191 format (Ethereum Signed Message)
43
- * This is used for signing webhook payloads for provider authentication
44
- *
45
- * Format: "\x19Ethereum Signed Message:\n{len}" + bytes
46
- * Then hash with Keccak256 and sign
47
- *
48
- * @param privateKey - Ethereum private key (0x prefixed hex string)
49
- * @param bytes - Raw bytes to sign
50
- * @returns Hex-encoded signature with 0x prefix (65 bytes: r + s + v)
51
- */
52
- export declare function signRawBytesWithEip191(privateKey: string, bytes: Uint8Array): Promise<string>;
@@ -1,144 +0,0 @@
1
- /**
2
- * Error classes for T3n SDK
3
- */
4
- /**
5
- * Base error class for T3n SDK errors
6
- */
7
- export declare class T3nError extends Error {
8
- readonly code?: string | undefined;
9
- constructor(message: string, code?: string | undefined);
10
- }
11
- /**
12
- * Error thrown when session is in invalid state for operation
13
- */
14
- export declare class SessionStateError extends T3nError {
15
- readonly currentState: string;
16
- constructor(message: string, currentState: string);
17
- }
18
- /**
19
- * Error thrown during authentication process
20
- */
21
- export declare class AuthenticationError extends T3nError {
22
- readonly authMethod?: string | undefined;
23
- constructor(message: string, authMethod?: string | undefined);
24
- }
25
- /**
26
- * Error thrown during handshake process
27
- */
28
- export declare class HandshakeError extends T3nError {
29
- constructor(message: string);
30
- }
31
- /**
32
- * Error thrown when a session-authenticated SDK client detects that the
33
- * caller-owned session is no longer usable and the caller must
34
- * re-authenticate before the call can succeed.
35
- *
36
- * Unlike {@link OrgDataClient} (which owns its ETH-secret-driven session
37
- * and silently rebuilds it on expiry), {@link SessionOrgDataClient} is
38
- * handed a caller-owned `T3nClient` whose session is bound to an
39
- * interactive flow (typically SIWE). The SDK can't re-authenticate
40
- * non-interactively, so on the same wire patterns that the
41
- * self-owned client recovers from, the session-bound client translates
42
- * the underlying error into this class and rethrows. The original error
43
- * is preserved on the native ES2022 `cause` property.
44
- *
45
- * Callers branch on `instanceof SessionExpiredError` to route the user
46
- * to a re-auth UX (e.g. SIWE modal / login redirect) rather than
47
- * parsing the message of a raw {@link RpcError}.
48
- */
49
- export declare class SessionExpiredError extends T3nError {
50
- constructor(cause: unknown);
51
- }
52
- /**
53
- * Error thrown during RPC communication.
54
- *
55
- * `message` is the human-readable error (preferring the server's
56
- * `error.data.detail` when present, with the request id appended in
57
- * `[<id>]` form so a UI that only surfaces `.message` still gives an
58
- * operator something to grep). The structured fields below preserve
59
- * the same info for callers that want to render or log them
60
- * separately — e.g. a toast that shows `detail` but surfaces
61
- * `requestId` in a "copy for support" affordance.
62
- */
63
- export declare class RpcError extends T3nError {
64
- readonly rpcMethod?: string | undefined;
65
- readonly httpStatus?: number | undefined;
66
- /** Server-attached detail (JSON-RPC `error.data.detail`). User-facing kinds
67
- * carry the specific reason here; internal kinds omit it. */
68
- readonly detail?: string | undefined;
69
- /** Per-request correlation id (JSON-RPC `error.data.request_id`). */
70
- readonly requestId?: string | undefined;
71
- constructor(message: string, rpcMethod?: string | undefined, httpStatus?: number | undefined,
72
- /** Server-attached detail (JSON-RPC `error.data.detail`). User-facing kinds
73
- * carry the specific reason here; internal kinds omit it. */
74
- detail?: string | undefined,
75
- /** Per-request correlation id (JSON-RPC `error.data.request_id`). */
76
- requestId?: string | undefined);
77
- }
78
- /**
79
- * Error thrown when the cluster's T3-TS-030 metering chargepoint
80
- * denies a contract-register or contract-invocation request because
81
- * the billing DID's available balance is below the operation's cost.
82
- *
83
- * Recognised by the SDK from a stable wire format the node emits
84
- * for the `ServiceError::InsufficientCredit` variant — see
85
- * `node/api/src/error.rs::service_insufficient_credit_wire_format_is_stable`.
86
- * Subclass of `RpcError` so callers that catch the parent still see
87
- * the structured `httpStatus` / `requestId` fields; callers that
88
- * want the typed surface (frontends rendering an "out of credit"
89
- * banner) `instanceof InsufficientCreditError` to read `available`
90
- * and `required` directly.
91
- *
92
- * Terminal — do NOT retry. The next call needs either a mint to
93
- * `account` (admin operation) or a reduction in the requested
94
- * operation's cost.
95
- */
96
- export declare class InsufficientCreditError extends RpcError {
97
- /** Hex DID (no `did:t3n:` prefix) the chargepoint billed. */
98
- readonly account: string;
99
- /** Tokens the chargepoint required (parsed from `required=`). */
100
- readonly required: bigint;
101
- /** Tokens available on `account` at check time (parsed from `available=`). */
102
- readonly available: bigint;
103
- constructor(message: string,
104
- /** Hex DID (no `did:t3n:` prefix) the chargepoint billed. */
105
- account: string,
106
- /** Tokens the chargepoint required (parsed from `required=`). */
107
- required: bigint,
108
- /** Tokens available on `account` at check time (parsed from `available=`). */
109
- available: bigint, rpcMethod?: string, requestId?: string);
110
- }
111
- /**
112
- * Try to parse the node's stable `InsufficientCredit (account=..., required=..., available=...)`
113
- * wire format. Returns the typed error on match, `null` otherwise.
114
- * Callers wrap RPC error construction in this so a Forbidden whose
115
- * detail matches the format surfaces as the typed class.
116
- *
117
- * The format is pinned by a server-side test
118
- * (`api/src/error.rs::service_insufficient_credit_wire_format_is_stable`)
119
- * so a node change that breaks this parser also breaks CI.
120
- */
121
- export declare function tryParseInsufficientCredit(message: string, rpcMethod?: string, requestId?: string): InsufficientCreditError | null;
122
- /**
123
- * Error thrown when WASM operations fail
124
- */
125
- export declare class WasmError extends T3nError {
126
- readonly operation?: string | undefined;
127
- readonly payload?: unknown | undefined;
128
- constructor(message: string, operation?: string | undefined, payload?: unknown | undefined);
129
- }
130
- /**
131
- * Decode WASM error message from comma-separated byte array format
132
- * WASM errors often come as "83,101,114,100,101..." which represents ASCII bytes
133
- *
134
- * @param errorMessage - The error message string that may contain comma-separated bytes
135
- * @returns Decoded error message if it was encoded, otherwise original message
136
- */
137
- export declare function decodeWasmErrorMessage(errorMessage: string): string;
138
- /**
139
- * Extract and decode error from WASM ComponentError
140
- *
141
- * @param error - The error object from WASM
142
- * @returns Decoded error message
143
- */
144
- export declare function extractWasmError(error: unknown): string;
@@ -1,10 +0,0 @@
1
- /**
2
- * Utility exports for T3n SDK
3
- */
4
- export * from "./crypto";
5
- export * from "./contract-version";
6
- export * from "./errors";
7
- export * from "./logger";
8
- export * from "./redaction";
9
- export * from "./session";
10
- export * from "./shape";
@@ -1,102 +0,0 @@
1
- /**
2
- * Logger interface and implementations for T3n SDK
3
- *
4
- * Provides hierarchical log level control (DEBUG, INFO, WARN, ERROR) with
5
- * global defaults and per-component override capabilities.
6
- *
7
- * ## Usage
8
- *
9
- * ```typescript
10
- * import { getLogger, setGlobalLogLevel, LogLevel } from '@t3n-sdk/logger';
11
- *
12
- * // Use the global logger (defaults to ERROR level)
13
- * const logger = getLogger();
14
- * logger.error("This will be logged");
15
- * logger.debug("This will NOT be logged by default");
16
- *
17
- * // Enable debug logging globally
18
- * setGlobalLogLevel(LogLevel.DEBUG);
19
- * const debugLogger = getLogger();
20
- * debugLogger.debug("This will now be logged");
21
- *
22
- * // Create a logger with a specific level (overrides global)
23
- * const infoLogger = createLogger(LogLevel.INFO);
24
- * infoLogger.info("This will be logged");
25
- * infoLogger.debug("This will NOT be logged");
26
- * ```
27
- *
28
- * ## Log Levels
29
- *
30
- * - `DEBUG` (0): Most verbose, logs everything
31
- * - `INFO` (1): Logs info, warnings, and errors
32
- * - `WARN` (2): Logs warnings and errors only
33
- * - `ERROR` (3): Logs errors only (default)
34
- */
35
- /**
36
- * Log levels in hierarchical order (lower values = more verbose)
37
- */
38
- export declare enum LogLevel {
39
- DEBUG = 0,
40
- INFO = 1,
41
- WARN = 2,
42
- ERROR = 3
43
- }
44
- /**
45
- * Logger interface for SDK debugging and monitoring
46
- */
47
- export interface Logger {
48
- /**
49
- * Log a debug message (most verbose)
50
- * @param args - Arguments to log
51
- */
52
- debug(...args: unknown[]): void;
53
- /**
54
- * Log an info message
55
- * @param args - Arguments to log
56
- */
57
- info(...args: unknown[]): void;
58
- /**
59
- * Log a warning message
60
- * @param args - Arguments to log
61
- */
62
- warn(...args: unknown[]): void;
63
- /**
64
- * Log an error message (least verbose)
65
- * @param args - Arguments to log
66
- */
67
- error(...args: unknown[]): void;
68
- }
69
- /**
70
- * Set the global default log level for all components
71
- *
72
- * This affects all loggers created without an explicit log level.
73
- * The default global log level is LogLevel.ERROR (only errors are logged).
74
- *
75
- * @param level - The log level to set as default for all components
76
- *
77
- * @example
78
- * ```typescript
79
- * // Enable debug logging globally
80
- * setGlobalLogLevel(LogLevel.DEBUG);
81
- *
82
- * // Only log errors (default)
83
- * setGlobalLogLevel(LogLevel.ERROR);
84
- * ```
85
- */
86
- export declare function setGlobalLogLevel(level: LogLevel): void;
87
- /**
88
- * Get the current global log level
89
- * @returns The current global log level (default: LogLevel.ERROR)
90
- */
91
- export declare function getGlobalLogLevel(): LogLevel;
92
- /**
93
- * Create a logger instance with the specified log level
94
- * @param level - The log level for this logger. If not provided, defaults to the global log level (LogLevel.ERROR).
95
- * @returns Logger instance configured with the specified or default log level
96
- */
97
- export declare function createLogger(level?: LogLevel): Logger;
98
- /**
99
- * Get a logger instance using the global log level
100
- * @returns Logger instance with global log level (default: LogLevel.ERROR)
101
- */
102
- export declare function getLogger(): Logger;
@@ -1,13 +0,0 @@
1
- /**
2
- * Secret redaction utilities for T3n SDK
3
- *
4
- * Provides functions to redact sensitive information before logging
5
- */
6
- /**
7
- * Redact secrets from values before logging
8
- */
9
- export declare function redactSecrets(value: unknown): unknown;
10
- /**
11
- * Redact secrets from a JSON string
12
- */
13
- export declare function redactSecretsFromJson(jsonString: string): string;