@terminal3/t3n-sdk 5.30.0 → 5.32.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/cli/index.js +1 -1
- package/dist/index.d.ts +17 -733
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/scripts/sign-trust-manifest.mjs +4 -4
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { T3nError, ListContractsParams, ListContractsResult, GrantCheckParams, GrantCheckResult, ContractResponseSchema, Environment } from '@terminal3/t3n-client';
|
|
2
|
+
export { AuthenticationError, BASE_UNITS_PER_TOKEN, ContractDescriptorDocument, ContractKind, ContractResponseError, ContractResponseSchema, DEFAULT_ENVIRONMENT, DelegationGrantKind, DelegationGrantRef, DescribeContractParams, DescribeContractResult, DescribeFunctionParams, DescribeFunctionResult, DiscoverOptions, Environment, FunctionDescriptorEntry, GrantCheckParams, GrantCheckResult, HandshakeError, InvokeError, InvokeOptions, InvokeRequest, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, NODE_URLS, OtpRateLimitedError, RpcError, SessionExpiredError, SessionStateError, StatelessCredential, StringEncoding, T3nConfigError, T3nError, TOKEN_DECIMALS, WasmError, WhoamiResult, WireBlock, WireEncodingError, _b64uEncode, b64uDecodeStrict, b64uEncodeBytes, compactDidFromBytes, decodeWasmErrorMessage, discoverCheckDelegation, discoverDescribeContract, discoverDescribeFunction, discoverListContracts, discoverWhoami, extractWasmError, formatTokens, invoke, parseContractResponse, requestToWire, toBaseUnits } from '@terminal3/t3n-client';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* WASM Component Interface - Mirrors the WIT specification exactly
|
|
3
6
|
*
|
|
@@ -918,216 +921,12 @@ interface T3nClientConfig {
|
|
|
918
921
|
* Without this, a network attacker with their own TDX VM can hand the
|
|
919
922
|
* SDK a forged-but-valid attestation for a key it controls and read
|
|
920
923
|
* every session. It is a required field precisely so no caller can
|
|
921
|
-
* omit it by accident —
|
|
924
|
+
* omit it by accident — skipping verification must be a visible,
|
|
922
925
|
* grep-able choice.
|
|
923
926
|
*/
|
|
924
927
|
trustAnchor: TrustAnchorOrUnsafe;
|
|
925
928
|
}
|
|
926
929
|
|
|
927
|
-
/**
|
|
928
|
-
* Error classes for T3n SDK
|
|
929
|
-
*/
|
|
930
|
-
/**
|
|
931
|
-
* Base error class for T3n SDK errors
|
|
932
|
-
*/
|
|
933
|
-
declare class T3nError extends Error {
|
|
934
|
-
readonly code?: string | undefined;
|
|
935
|
-
constructor(message: string, code?: string | undefined);
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* Error thrown when the {@link T3nClientConfig} handed to the
|
|
939
|
-
* {@link T3nClient} constructor is invalid — a required field is
|
|
940
|
-
* missing or malformed. Thrown eagerly at construction so a
|
|
941
|
-
* misconfiguration fails fast with a named, grep-able error instead
|
|
942
|
-
* of crashing deep in the handshake.
|
|
943
|
-
*
|
|
944
|
-
* The `field` names the offending config key so callers can branch or
|
|
945
|
-
* log with full fidelity rather than parsing the message.
|
|
946
|
-
*/
|
|
947
|
-
declare class T3nConfigError extends T3nError {
|
|
948
|
-
readonly field?: string | undefined;
|
|
949
|
-
constructor(message: string, field?: string | undefined);
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Error thrown when session is in invalid state for operation
|
|
953
|
-
*/
|
|
954
|
-
declare class SessionStateError extends T3nError {
|
|
955
|
-
readonly currentState: string;
|
|
956
|
-
constructor(message: string, currentState: string);
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* Error thrown during authentication process
|
|
960
|
-
*/
|
|
961
|
-
declare class AuthenticationError extends T3nError {
|
|
962
|
-
readonly authMethod?: string | undefined;
|
|
963
|
-
constructor(message: string, authMethod?: string | undefined);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Error thrown during handshake process
|
|
967
|
-
*/
|
|
968
|
-
declare class HandshakeError extends T3nError {
|
|
969
|
-
constructor(message: string);
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Error thrown when a session-authenticated SDK client detects that the
|
|
973
|
-
* caller-owned session is no longer usable and the caller must
|
|
974
|
-
* re-authenticate before the call can succeed.
|
|
975
|
-
*
|
|
976
|
-
* Unlike {@link OrgDataClient} (which owns its ETH-secret-driven session
|
|
977
|
-
* and silently rebuilds it on expiry), {@link SessionOrgDataClient} is
|
|
978
|
-
* handed a caller-owned `T3nClient` whose session is bound to an
|
|
979
|
-
* interactive flow (typically SIWE). The SDK can't re-authenticate
|
|
980
|
-
* non-interactively, so on the same wire patterns that the
|
|
981
|
-
* self-owned client recovers from, the session-bound client translates
|
|
982
|
-
* the underlying error into this class and rethrows. The original error
|
|
983
|
-
* is preserved on the native ES2022 `cause` property.
|
|
984
|
-
*
|
|
985
|
-
* Callers branch on `instanceof SessionExpiredError` to route the user
|
|
986
|
-
* to a re-auth UX (e.g. SIWE modal / login redirect) rather than
|
|
987
|
-
* parsing the message of a raw {@link RpcError}.
|
|
988
|
-
*/
|
|
989
|
-
declare class SessionExpiredError extends T3nError {
|
|
990
|
-
constructor(cause: unknown);
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Error thrown during RPC communication.
|
|
994
|
-
*
|
|
995
|
-
* `message` is the human-readable error (preferring the server's
|
|
996
|
-
* `error.data.detail` when present, with the request id appended in
|
|
997
|
-
* `[<id>]` form so a UI that only surfaces `.message` still gives an
|
|
998
|
-
* operator something to grep). The structured fields below preserve
|
|
999
|
-
* the same info for callers that want to render or log them
|
|
1000
|
-
* separately — e.g. a toast that shows `detail` but surfaces
|
|
1001
|
-
* `requestId` in a "copy for support" affordance.
|
|
1002
|
-
*/
|
|
1003
|
-
declare class RpcError extends T3nError {
|
|
1004
|
-
readonly rpcMethod?: string | undefined;
|
|
1005
|
-
readonly httpStatus?: number | undefined;
|
|
1006
|
-
/** Server-attached detail (JSON-RPC `error.data.detail`). User-facing kinds
|
|
1007
|
-
* carry the specific reason here; internal kinds omit it. */
|
|
1008
|
-
readonly detail?: string | undefined;
|
|
1009
|
-
/** Per-request correlation id (JSON-RPC `error.data.request_id`). */
|
|
1010
|
-
readonly requestId?: string | undefined;
|
|
1011
|
-
constructor(message: string, rpcMethod?: string | undefined, httpStatus?: number | undefined,
|
|
1012
|
-
/** Server-attached detail (JSON-RPC `error.data.detail`). User-facing kinds
|
|
1013
|
-
* carry the specific reason here; internal kinds omit it. */
|
|
1014
|
-
detail?: string | undefined,
|
|
1015
|
-
/** Per-request correlation id (JSON-RPC `error.data.request_id`). */
|
|
1016
|
-
requestId?: string | undefined);
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Error thrown when an OTP send is throttled by the node.
|
|
1020
|
-
*
|
|
1021
|
-
* The email-OTP login flow's `InitEmailOtp` step refuses a send when a
|
|
1022
|
-
* still-valid code was issued within the resend cooldown
|
|
1023
|
-
* (`reason: "cooldown_active"`) or the rolling per-recipient send cap is
|
|
1024
|
-
* exhausted (`reason: "send_cap_exceeded"`). Previously a cooldown-
|
|
1025
|
-
* suppressed resend returned a silent success, leaving a user who never
|
|
1026
|
-
* received the first code at a dead end; this typed error lets the app
|
|
1027
|
-
* render a "you just requested a code — retry in {retryAfterSecs}s"
|
|
1028
|
-
* affordance instead.
|
|
1029
|
-
*
|
|
1030
|
-
* Recognised from the node's stable
|
|
1031
|
-
* `OtpRateLimited (reason=…, retry_after_secs=…)` wire token (pinned by a
|
|
1032
|
-
* server-side test). Subclass of {@link RpcError} so callers that catch
|
|
1033
|
-
* the parent still see `httpStatus`/`requestId`; callers that want the
|
|
1034
|
-
* typed surface `instanceof OtpRateLimitedError` to read `reason` and
|
|
1035
|
-
* `retryAfterSecs`.
|
|
1036
|
-
*
|
|
1037
|
-
* Retryable after `retryAfterSecs` (caller-side back-off).
|
|
1038
|
-
*/
|
|
1039
|
-
declare class OtpRateLimitedError extends RpcError {
|
|
1040
|
-
/** Stable reason code: `"cooldown_active"` or `"send_cap_exceeded"`. */
|
|
1041
|
-
readonly reason: string;
|
|
1042
|
-
/** Seconds to wait before retrying the send (parsed from `retry_after_secs=`). */
|
|
1043
|
-
readonly retryAfterSecs: number;
|
|
1044
|
-
constructor(message: string,
|
|
1045
|
-
/** Stable reason code: `"cooldown_active"` or `"send_cap_exceeded"`. */
|
|
1046
|
-
reason: string,
|
|
1047
|
-
/** Seconds to wait before retrying the send (parsed from `retry_after_secs=`). */
|
|
1048
|
-
retryAfterSecs: number, rpcMethod?: string, requestId?: string);
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Error thrown when WASM operations fail
|
|
1052
|
-
*/
|
|
1053
|
-
declare class WasmError extends T3nError {
|
|
1054
|
-
readonly operation?: string | undefined;
|
|
1055
|
-
readonly payload?: unknown | undefined;
|
|
1056
|
-
constructor(message: string, operation?: string | undefined, payload?: unknown | undefined);
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* Decode WASM error message from comma-separated byte array format
|
|
1060
|
-
* WASM errors often come as "83,101,114,100,101..." which represents ASCII bytes
|
|
1061
|
-
*
|
|
1062
|
-
* @param errorMessage - The error message string that may contain comma-separated bytes
|
|
1063
|
-
* @returns Decoded error message if it was encoded, otherwise original message
|
|
1064
|
-
*/
|
|
1065
|
-
declare function decodeWasmErrorMessage(errorMessage: string): string;
|
|
1066
|
-
/**
|
|
1067
|
-
* Extract and decode error from WASM ComponentError
|
|
1068
|
-
*
|
|
1069
|
-
* @param error - The error object from WASM
|
|
1070
|
-
* @returns Decoded error message
|
|
1071
|
-
*/
|
|
1072
|
-
declare function extractWasmError(error: unknown): string;
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Contract response decoding for {@link T3nClient.execute}.
|
|
1076
|
-
*
|
|
1077
|
-
* ## On-wire shape
|
|
1078
|
-
*
|
|
1079
|
-
* Trinity contracts are declared as `result<list<u8>, string>` in WIT and
|
|
1080
|
-
* return JSON-encoded bytes. The server-side pipeline is:
|
|
1081
|
-
*
|
|
1082
|
-
* 1. The contract's returned bytes are deserialized into a JSON `Value`
|
|
1083
|
-
* (the contract's decoded return value).
|
|
1084
|
-
* 2. The host wraps that value in an internal `ContractResponse` struct
|
|
1085
|
-
* for bookkeeping — it carries an extracted `otp_state` alongside the
|
|
1086
|
-
* response.
|
|
1087
|
-
* 3. The host then unwraps the struct, discarding the `otp_state` field
|
|
1088
|
-
* and returning only the inner `Value` across the executor boundary.
|
|
1089
|
-
* 4. That plain `Value` is serialised through the session channel.
|
|
1090
|
-
*
|
|
1091
|
-
* The client therefore receives the contract's **decoded JSON value
|
|
1092
|
-
* directly** — no `{response, otp_state}` envelope, despite what the
|
|
1093
|
-
* struct name suggests. `parseContractResponse` reflects that reality:
|
|
1094
|
-
* it does a typed `JSON.parse` with optional schema validation, nothing
|
|
1095
|
-
* more. OTP flows read their `otp_status` / OTP fields directly off the
|
|
1096
|
-
* contract's response body; there is no separate envelope field for them
|
|
1097
|
-
* on this path.
|
|
1098
|
-
*/
|
|
1099
|
-
|
|
1100
|
-
/**
|
|
1101
|
-
* Minimal validator interface. Any library that exposes `.parse(value) -> T`
|
|
1102
|
-
* (zod, valibot, superstruct, custom) is compatible.
|
|
1103
|
-
*/
|
|
1104
|
-
interface ContractResponseSchema<T> {
|
|
1105
|
-
parse(value: unknown): T;
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Thrown when the response string from {@link T3nClient.execute} cannot
|
|
1109
|
-
* be parsed as JSON.
|
|
1110
|
-
*
|
|
1111
|
-
* Schema-validation failures are NOT wrapped — they surface as whatever
|
|
1112
|
-
* error the caller's validator throws, preserving the rich diagnostics
|
|
1113
|
-
* those libraries already provide.
|
|
1114
|
-
*/
|
|
1115
|
-
declare class ContractResponseError extends T3nError {
|
|
1116
|
-
readonly raw?: string | undefined;
|
|
1117
|
-
constructor(message: string, raw?: string | undefined);
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* Parse the JSON-encoded response returned by {@link T3nClient.execute}
|
|
1121
|
-
* into a typed value.
|
|
1122
|
-
*
|
|
1123
|
-
* @param raw - the string returned by {@link T3nClient.execute}
|
|
1124
|
-
* @param schema - optional validator applied to the parsed value
|
|
1125
|
-
* @returns the decoded response, typed as `T`
|
|
1126
|
-
* @throws {ContractResponseError} when `raw` is not valid JSON
|
|
1127
|
-
* @throws whatever the schema throws on validation failure (e.g. `ZodError`)
|
|
1128
|
-
*/
|
|
1129
|
-
declare function parseContractResponse<T = unknown>(raw: string, schema?: ContractResponseSchema<T>): T;
|
|
1130
|
-
|
|
1131
930
|
/**
|
|
1132
931
|
* Delegated agents and the T3N OAuth connections that act as them. Wire types
|
|
1133
932
|
* and strict decoders for the functions the `T3nClient` wrappers dispatch:
|
|
@@ -2795,210 +2594,6 @@ interface ActivityExportFile {
|
|
|
2795
2594
|
csv: string;
|
|
2796
2595
|
}
|
|
2797
2596
|
|
|
2798
|
-
/**
|
|
2799
|
-
* Contract-discovery wire shapes.
|
|
2800
|
-
*
|
|
2801
|
-
* Field-for-field mirrors of the node's `contracts.list` and `delegation.check`
|
|
2802
|
-
* JSON-RPC responses (`service::contract_discovery::{ListedContract,
|
|
2803
|
-
* ListContractsResponse}` and `service::grant_check::{GrantRef,
|
|
2804
|
-
* GrantCheckResponse}`). Both methods are session-authenticated plaintext reads
|
|
2805
|
-
* dispatched over `/api/rpc` — the same posture as `token.get-usage` — so the
|
|
2806
|
-
* SDK wrappers return the parsed `result` object directly.
|
|
2807
|
-
*/
|
|
2808
|
-
/** The navigable starting points of the discovery funnel. */
|
|
2809
|
-
type ListContractsScope = "core" | "org" | "self";
|
|
2810
|
-
/** Params for `contracts.list` (every field optional; `{}` lists core). */
|
|
2811
|
-
interface ListContractsParams {
|
|
2812
|
-
/** `"core"` (default) | `"org"` | `"self"`. */
|
|
2813
|
-
scope?: ListContractsScope;
|
|
2814
|
-
/** Target org DID (required for scope `"org"`). */
|
|
2815
|
-
org_did?: string;
|
|
2816
|
-
/** The member the agent acts for (required for scope `"org"` / `"self"`). */
|
|
2817
|
-
pii_did?: string;
|
|
2818
|
-
/** Page offset (defaults to 0 server-side). */
|
|
2819
|
-
offset?: number;
|
|
2820
|
-
/** Page size (defaults + clamped server-side). */
|
|
2821
|
-
limit?: number;
|
|
2822
|
-
}
|
|
2823
|
-
/** Contract kind — `"core"` platform system contract, `"tenant"` z-space. */
|
|
2824
|
-
type ContractKind = "core" | "tenant";
|
|
2825
|
-
/** One contract as presented by `contracts.list`. */
|
|
2826
|
-
interface ListedContract {
|
|
2827
|
-
/** Canonical name: `tee:<name>` for core, `z:<tid>:<tail>` for tenant. */
|
|
2828
|
-
name: string;
|
|
2829
|
-
kind: ContractKind;
|
|
2830
|
-
/** Current registered version; `null` when the contract is not registered. */
|
|
2831
|
-
version: string | null;
|
|
2832
|
-
/** Descriptor summary, or empty when no descriptor is published. */
|
|
2833
|
-
summary: string;
|
|
2834
|
-
/** Descriptor tags, or empty. */
|
|
2835
|
-
tags: string[];
|
|
2836
|
-
/** Owning DID: the org DID (org mode) or the member's own DID (self mode). */
|
|
2837
|
-
owner_org_did?: string;
|
|
2838
|
-
/**
|
|
2839
|
-
* Human-facing short name: the trailing segment of `name` (`payroll` from
|
|
2840
|
-
* `z:<tid>:payroll`, `user` from `tee:user`). Present this to people instead
|
|
2841
|
-
* of the full canonical `name`, which remains the dispatch key.
|
|
2842
|
-
*/
|
|
2843
|
-
short_name: string;
|
|
2844
|
-
}
|
|
2845
|
-
/** Response body for `contracts.list`. */
|
|
2846
|
-
interface ListContractsResult {
|
|
2847
|
-
scope: string;
|
|
2848
|
-
contracts: ListedContract[];
|
|
2849
|
-
next_offset: number | null;
|
|
2850
|
-
}
|
|
2851
|
-
/**
|
|
2852
|
-
* Which standing grant a satisfied/missing entry refers to — the stable,
|
|
2853
|
-
* caller-facing values. Reads are normalised to these two, so switch logic on
|
|
2854
|
-
* them stays exhaustive.
|
|
2855
|
-
*/
|
|
2856
|
-
type DelegationGrantKind = "member_delegation" | "org_delegation";
|
|
2857
|
-
/** Params for `delegation.check` (the generic capability read). */
|
|
2858
|
-
interface GrantCheckParams {
|
|
2859
|
-
/** The target contract whose requirements are checked. */
|
|
2860
|
-
contract: string;
|
|
2861
|
-
/** The member the agent wants to act for (the subject). */
|
|
2862
|
-
pii_did: string;
|
|
2863
|
-
/** Functions the intended action needs. */
|
|
2864
|
-
functions: string[];
|
|
2865
|
-
/** Org-data scopes the intended action needs. */
|
|
2866
|
-
scopes: string[];
|
|
2867
|
-
}
|
|
2868
|
-
/** One grant requirement — satisfied or missing. */
|
|
2869
|
-
interface DelegationGrantRef {
|
|
2870
|
-
grant: DelegationGrantKind;
|
|
2871
|
-
/** The target contract's canonical name. */
|
|
2872
|
-
contract: string;
|
|
2873
|
-
functions: string[];
|
|
2874
|
-
scopes: string[];
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* Response for `delegation.check`: the `member_delegation ∩ org_delegation` verdict.
|
|
2878
|
-
*
|
|
2879
|
-
* `disclosed` is `true` only when the agent is registered under `pii_did`, so
|
|
2880
|
-
* org-side status was safe to disclose; `false` yields the uniform,
|
|
2881
|
-
* non-disclosive verdict (`authorised:false, satisfied:[], missing:[]`) that is
|
|
2882
|
-
* byte-invariant to the requested capability (R5 anti-enumeration).
|
|
2883
|
-
*/
|
|
2884
|
-
interface GrantCheckResult {
|
|
2885
|
-
authorised: boolean;
|
|
2886
|
-
disclosed: boolean;
|
|
2887
|
-
satisfied: DelegationGrantRef[];
|
|
2888
|
-
missing: DelegationGrantRef[];
|
|
2889
|
-
}
|
|
2890
|
-
/** Response for the `whoami` operation: who the key resolves to, and where. */
|
|
2891
|
-
interface WhoamiResult {
|
|
2892
|
-
/** The DID the relayed api key resolves to. */
|
|
2893
|
-
did: string;
|
|
2894
|
-
/**
|
|
2895
|
-
* The org DIDs the agent itself belongs to (its own agent-keyed membership),
|
|
2896
|
-
* or `[]` when it belongs to none. Each is a valid `org_did` for
|
|
2897
|
-
* `contracts.list` scope `"org"`, so this is the seed for browsing the agent's
|
|
2898
|
-
* own orgs.
|
|
2899
|
-
*/
|
|
2900
|
-
organisations: string[];
|
|
2901
|
-
/**
|
|
2902
|
-
* The agent's owning / managing DID — usually the org that created it. `null`
|
|
2903
|
-
* for a missing record (agents created without a hosted card or agent URI have
|
|
2904
|
-
* no registry record), a record with no owner link, or a malformed record
|
|
2905
|
-
* (decode failure is logged at `WARN`, never a silent authority downgrade); a
|
|
2906
|
-
* snapshot read failure is surfaced as an error, not reported as `null`. The
|
|
2907
|
-
* owner link is mutable and may have changed since creation, so treat this as
|
|
2908
|
-
* best-effort, not an authority.
|
|
2909
|
-
*/
|
|
2910
|
-
owner: string | null;
|
|
2911
|
-
/**
|
|
2912
|
-
* A delegated agent's display name, as its owner named it. `null` for an
|
|
2913
|
-
* api-key agent; absent from a node that predates the field.
|
|
2914
|
-
*/
|
|
2915
|
-
name?: string | null;
|
|
2916
|
-
}
|
|
2917
|
-
/** Params for the `describe.contract` operation. */
|
|
2918
|
-
interface DescribeContractParams {
|
|
2919
|
-
/**
|
|
2920
|
-
* Registry name: `tee:<name>/contracts` (core) or `z:<tid>:<tail>` (tenant).
|
|
2921
|
-
* The bare core form `contracts.list` presents (`tee:<name>` / `y:<name>`) is
|
|
2922
|
-
* also accepted — the node maps it onto the `/contracts` registry key — so a
|
|
2923
|
-
* `ListedContract.name` feeds straight in.
|
|
2924
|
-
*/
|
|
2925
|
-
contract: string;
|
|
2926
|
-
/** Explicit version; omitted resolves the current registered version. */
|
|
2927
|
-
version?: string;
|
|
2928
|
-
}
|
|
2929
|
-
/** Params for the `describe.function` operation. */
|
|
2930
|
-
interface DescribeFunctionParams {
|
|
2931
|
-
/**
|
|
2932
|
-
* Registry name: `tee:<name>/contracts` (core) or `z:<tid>:<tail>` (tenant).
|
|
2933
|
-
* The bare core form `contracts.list` presents (`tee:<name>` / `y:<name>`) is
|
|
2934
|
-
* also accepted — the node maps it onto the `/contracts` registry key.
|
|
2935
|
-
*/
|
|
2936
|
-
contract: string;
|
|
2937
|
-
/** The single function to project from the contract's descriptor. */
|
|
2938
|
-
function: string;
|
|
2939
|
-
/** Explicit version; omitted resolves the current registered version. */
|
|
2940
|
-
version?: string;
|
|
2941
|
-
}
|
|
2942
|
-
/**
|
|
2943
|
-
* One function's descriptor entry — the `describe.function` result and the
|
|
2944
|
-
* element type of a {@link ContractDescriptorDocument}'s `functions` array.
|
|
2945
|
-
*
|
|
2946
|
-
* Left open-ended: the descriptor document's full schema (argument schema,
|
|
2947
|
-
* wire projection, auth requirements) is owned by the contract descriptor
|
|
2948
|
-
* registry and served verbatim by the node. The named fields are the ones the
|
|
2949
|
-
* node's descriptor path always presents.
|
|
2950
|
-
*/
|
|
2951
|
-
interface FunctionDescriptorEntry {
|
|
2952
|
-
/** Contract function name (e.g. `compute-payroll`). */
|
|
2953
|
-
name: string;
|
|
2954
|
-
summary?: string;
|
|
2955
|
-
/** Whether the function mutates state. */
|
|
2956
|
-
mutates?: boolean;
|
|
2957
|
-
[key: string]: unknown;
|
|
2958
|
-
}
|
|
2959
|
-
/**
|
|
2960
|
-
* The node's descriptor document for a contract — the `descriptor` field of a
|
|
2961
|
-
* {@link DescribeContractResult}. Open-ended for the same reason as
|
|
2962
|
-
* {@link FunctionDescriptorEntry}: the node returns the registry's descriptor
|
|
2963
|
-
* document verbatim.
|
|
2964
|
-
*/
|
|
2965
|
-
interface ContractDescriptorDocument {
|
|
2966
|
-
name?: string;
|
|
2967
|
-
version?: string;
|
|
2968
|
-
summary?: string;
|
|
2969
|
-
tags?: string[];
|
|
2970
|
-
functions?: FunctionDescriptorEntry[];
|
|
2971
|
-
[key: string]: unknown;
|
|
2972
|
-
}
|
|
2973
|
-
/**
|
|
2974
|
-
* Result of the `describe.contract` operation. The node wraps the descriptor
|
|
2975
|
-
* document with the resolved dispatch `version`, so an authorised describe hands
|
|
2976
|
-
* back the exact `scriptVersion` an {@link invoke} call needs alongside the
|
|
2977
|
-
* schema. Returned only on the authorised path; a gate miss or unknown contract
|
|
2978
|
-
* yields the uniform non-disclosive error, never this wrapper.
|
|
2979
|
-
*/
|
|
2980
|
-
interface DescribeContractResult {
|
|
2981
|
-
/** The canonical registry name, echoed from the request. */
|
|
2982
|
-
contract: string;
|
|
2983
|
-
/** The resolved dispatch version — pass as `scriptVersion` to `invoke`. */
|
|
2984
|
-
version: string;
|
|
2985
|
-
/** The contract's full descriptor document. */
|
|
2986
|
-
descriptor: ContractDescriptorDocument;
|
|
2987
|
-
}
|
|
2988
|
-
/**
|
|
2989
|
-
* Result of the `describe.function` operation: the resolved dispatch `version`
|
|
2990
|
-
* paired with the single projected function entry. Same authorised-path-only
|
|
2991
|
-
* guarantee as {@link DescribeContractResult}.
|
|
2992
|
-
*/
|
|
2993
|
-
interface DescribeFunctionResult {
|
|
2994
|
-
/** The canonical registry name, echoed from the request. */
|
|
2995
|
-
contract: string;
|
|
2996
|
-
/** The resolved dispatch version — pass as `scriptVersion` to `invoke`. */
|
|
2997
|
-
version: string;
|
|
2998
|
-
/** The single projected function's descriptor entry. */
|
|
2999
|
-
descriptor: FunctionDescriptorEntry;
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3002
2597
|
/**
|
|
3003
2598
|
* T3n Client - Main SDK class
|
|
3004
2599
|
*
|
|
@@ -3107,7 +2702,7 @@ declare class T3nClient {
|
|
|
3107
2702
|
/**
|
|
3108
2703
|
* OIDC two-step authentication with session-binding nonce.
|
|
3109
2704
|
*
|
|
3110
|
-
*
|
|
2705
|
+
* Skips the WASM client state machine and makes two encrypted
|
|
3111
2706
|
* RPC calls directly:
|
|
3112
2707
|
* 1. `InitOidcAuth { provider }` → server generates nonce → returns
|
|
3113
2708
|
* `ProvideNonce { nonce }`.
|
|
@@ -3118,7 +2713,7 @@ declare class T3nClient {
|
|
|
3118
2713
|
private authenticateOidc;
|
|
3119
2714
|
/**
|
|
3120
2715
|
* Parse a `Finish { did }` reply shared by the manual (non-WASM) auth flows
|
|
3121
|
-
* that
|
|
2716
|
+
* that skip the client state machine (interactive OIDC, keyless workload).
|
|
3122
2717
|
*
|
|
3123
2718
|
* Validates the `oidc_auth_action` tag before reading `did`: a decodable but
|
|
3124
2719
|
* non-`Finish` reply is reported as such rather than silently misread as a
|
|
@@ -3142,7 +2737,7 @@ declare class T3nClient {
|
|
|
3142
2737
|
* the token and mints/resolves the DID `oidc:<iss>:<sub>` →
|
|
3143
2738
|
* returns `Finish { did }`.
|
|
3144
2739
|
*
|
|
3145
|
-
*
|
|
2740
|
+
* Skips the WASM client state machine (mirrors `authenticateOidc` /
|
|
3146
2741
|
* `authenticateEmailOtp`); the `SubmitWorkloadToken` action tag is
|
|
3147
2742
|
* matched server-side.
|
|
3148
2743
|
*/
|
|
@@ -3150,7 +2745,7 @@ declare class T3nClient {
|
|
|
3150
2745
|
/**
|
|
3151
2746
|
* Email-OTP two-step authentication.
|
|
3152
2747
|
*
|
|
3153
|
-
* Symmetric with {@link authenticateOidc}:
|
|
2748
|
+
* Symmetric with {@link authenticateOidc}: skips the WASM client
|
|
3154
2749
|
* state machine and makes two encrypted RPC calls directly:
|
|
3155
2750
|
* 1. `InitEmailOtp { email }` → node sends a one-time code → returns
|
|
3156
2751
|
* an `OtpSent` ack.
|
|
@@ -4170,7 +3765,7 @@ declare class T3nClient {
|
|
|
4170
3765
|
*
|
|
4171
3766
|
* The KYC webhook orphan-attestation flow stays here: when
|
|
4172
3767
|
* `requireExistingUser` is set, the contract identifies the user
|
|
4173
|
-
* by DID (vendorData) instead of email and the gate
|
|
3768
|
+
* by DID (vendorData) instead of email and the email gate does not apply.
|
|
4174
3769
|
*
|
|
4175
3770
|
* @throws {UserUpsertError} when the contract returns a typed
|
|
4176
3771
|
* error (`email_not_verified`, `legacy_field`, `user_not_found`).
|
|
@@ -4526,250 +4121,6 @@ declare function createRandomHandler(): GuestToHostHandler;
|
|
|
4526
4121
|
*/
|
|
4527
4122
|
declare function createDefaultHandlers(baseUrl: string, trustAnchor: TrustAnchorOrUnsafe): GuestToHostHandlers;
|
|
4528
4123
|
|
|
4529
|
-
/**
|
|
4530
|
-
* Stateless agent auth: an API key or an OAuth bearer.
|
|
4531
|
-
*
|
|
4532
|
-
* `invoke` posts once to `POST /api/invoke` — an HTTPS-only
|
|
4533
|
-
* endpoint (see the HTTPS-guard note below) that authenticates an agent by
|
|
4534
|
-
* one {@link StatelessCredential}: an org agent's opaque API key
|
|
4535
|
-
* (`X-T3N-Api-Key: t3n_key_<...>`) or a delegated agent's OAuth access token
|
|
4536
|
-
* (`Authorization: Bearer <token>`), and executes a
|
|
4537
|
-
* `z:` contract as that agent in the SAME request. Unlike
|
|
4538
|
-
* {@link T3nClient.execute}, there is **no** ML-KEM handshake, **no**
|
|
4539
|
-
* `Session-Id`, and **no** session state: the node derives the acting agent
|
|
4540
|
-
* DID from the relayed key per-call (`resolve_stateless_credential`
|
|
4541
|
-
* driving the session contract's `api_key` action), then runs the same
|
|
4542
|
-
* execute pipeline `action.execute` runs after `check_authentication`
|
|
4543
|
-
* (`ActionService::execute_as_did`), and returns the contract's decoded
|
|
4544
|
-
* result as a plain `Json(result)` body — NOT a JSON-RPC envelope.
|
|
4545
|
-
*
|
|
4546
|
-
* Because the response is the bare decoded value (no `{jsonrpc,result,id}`
|
|
4547
|
-
* wrapper to unwrap), decoding reuses {@link parseContractResponse} — the
|
|
4548
|
-
* exact same JSON.parse + optional-schema path {@link T3nClient.executeAndDecode}
|
|
4549
|
-
* uses for the session `execute` RPC — so callers get identical typed /
|
|
4550
|
-
* schema-validated decoding on either path.
|
|
4551
|
-
*
|
|
4552
|
-
* This module intentionally does NOT import {@link T3nClient}, the WASM
|
|
4553
|
-
* component loader, or any handshake/session machinery — `invoke` is
|
|
4554
|
-
* a single fetch, nothing else.
|
|
4555
|
-
*
|
|
4556
|
-
* ### Keyed discovery transports
|
|
4557
|
-
* Alongside `invoke` (which acts), this module exports the keyed **discovery**
|
|
4558
|
-
* reads — {@link discoverWhoami}, {@link discoverListContracts},
|
|
4559
|
-
* {@link discoverCheckDelegation}, {@link discoverDescribeContract},
|
|
4560
|
-
* {@link discoverDescribeFunction}. They are the api-key counterpart of the
|
|
4561
|
-
* session `T3nClient.listContracts` / `checkDelegation` reads: each POSTs a
|
|
4562
|
-
* `{ method, params }` envelope to the node's `POST /api/discover` with the
|
|
4563
|
-
* same `X-T3N-Api-Key` header, HTTPS guard, timeout, and key-safe error
|
|
4564
|
-
* hygiene as `invoke`, and returns the node's raw JSON result. The session
|
|
4565
|
-
* `T3nClient` methods are untouched — these live beside `invoke`, off the
|
|
4566
|
-
* session client, so the relay reads never open a session. Every transport
|
|
4567
|
-
* shares the {@link postKeyed} core, so there is one implementation of the
|
|
4568
|
-
* secure-transport + secret-hygiene rules below, not two.
|
|
4569
|
-
*
|
|
4570
|
-
* ### HTTPS guard
|
|
4571
|
-
* The API key is a long-lived bearer credential relayed in a plain header,
|
|
4572
|
-
* so `invoke` refuses to send it over an insecure transport: `baseUrl`
|
|
4573
|
-
* must be `https:`, unless the host is a local-dev loopback
|
|
4574
|
-
* (`localhost` / `127.0.0.1` / `[::1]`), in which case plain `http:` is
|
|
4575
|
-
* allowed. The check runs before any network activity — an insecure
|
|
4576
|
-
* `baseUrl` never gets as far as a `fetch` call.
|
|
4577
|
-
*
|
|
4578
|
-
* ### Error hygiene
|
|
4579
|
-
* Every error `invoke` throws is a fixed, generic
|
|
4580
|
-
* {@link InvokeError} message — the response body text, the
|
|
4581
|
-
* underlying network error's message, and the api key are never
|
|
4582
|
-
* interpolated into it. This is defense in depth against a server (or a
|
|
4583
|
-
* malicious intermediary) that echoes the key or other secrets back in an
|
|
4584
|
-
* error body: whatever comes back over the wire on a non-2xx response is
|
|
4585
|
-
* discarded, not surfaced. The timeout timer also stays armed until the
|
|
4586
|
-
* response body has been fully read (or has itself timed out) — see
|
|
4587
|
-
* {@link invoke}'s implementation — so a connection that delivers
|
|
4588
|
-
* headers and then stalls on the body still respects `timeoutMs`.
|
|
4589
|
-
*/
|
|
4590
|
-
|
|
4591
|
-
/**
|
|
4592
|
-
* Wire body for `POST /api/invoke` — mirrors the server's
|
|
4593
|
-
* server-side `ExecuteActionRequest`, the same shape
|
|
4594
|
-
* `T3nClient`'s `execute*` wrappers build for the session `action.execute`
|
|
4595
|
-
* RPC. Field names are load-bearing: the server deserialises strictly into
|
|
4596
|
-
* `contract_id` / `contract_version` / `function_name` (see
|
|
4597
|
-
* `T3nClient.executeSystemContract`'s doc comment) — `contract` / `version`
|
|
4598
|
-
* / `function` produce a 400.
|
|
4599
|
-
*/
|
|
4600
|
-
interface InvokeRequest {
|
|
4601
|
-
contract_id: string;
|
|
4602
|
-
contract_version: string;
|
|
4603
|
-
function_name: string;
|
|
4604
|
-
/** Delegated-call target member; omitted for a self (non-delegated) call. */
|
|
4605
|
-
pii_did?: string;
|
|
4606
|
-
input?: unknown;
|
|
4607
|
-
}
|
|
4608
|
-
/**
|
|
4609
|
-
* The credential `/api/invoke` and `/api/discover` resolve, exactly one of:
|
|
4610
|
-
*
|
|
4611
|
-
* - `apiKey`: an org agent's opaque API key (`t3n_key_<...>`), sent as
|
|
4612
|
-
* `X-T3N-Api-Key`;
|
|
4613
|
-
* - `bearer`: a delegated agent's OAuth access token, sent as
|
|
4614
|
-
* `Authorization: Bearer <token>`.
|
|
4615
|
-
*
|
|
4616
|
-
* The node resolves either on the same routes (its `stateless_credential`
|
|
4617
|
-
* action tries the bearer first). Relayed verbatim, never logged and never
|
|
4618
|
-
* interpolated into any error this module throws.
|
|
4619
|
-
*/
|
|
4620
|
-
type StatelessCredential = {
|
|
4621
|
-
apiKey: string;
|
|
4622
|
-
bearer?: never;
|
|
4623
|
-
} | {
|
|
4624
|
-
bearer: string;
|
|
4625
|
-
apiKey?: never;
|
|
4626
|
-
};
|
|
4627
|
-
/** Options for {@link invoke}. */
|
|
4628
|
-
type InvokeOptions = StatelessCredential & {
|
|
4629
|
-
/**
|
|
4630
|
-
* RPC base URL of the T3n node, e.g. `https://node.example.com`. Must be
|
|
4631
|
-
* `https:` unless the host is a local-dev loopback (`localhost` /
|
|
4632
|
-
* `127.0.0.1` / `[::1]`) — see the module doc comment's HTTPS-guard note.
|
|
4633
|
-
*/
|
|
4634
|
-
baseUrl: string;
|
|
4635
|
-
/** The wire request to execute, built to the {@link InvokeRequest} shape. */
|
|
4636
|
-
request: InvokeRequest;
|
|
4637
|
-
/** Fetch timeout in ms. Defaults to 30s, matching {@link HttpTransport}. */
|
|
4638
|
-
timeoutMs?: number;
|
|
4639
|
-
};
|
|
4640
|
-
/**
|
|
4641
|
-
* Thrown when `POST /api/invoke` fails at the transport or HTTP
|
|
4642
|
-
* layer (network failure, timeout, non-2xx status). Contract-level errors
|
|
4643
|
-
* the node returns as a 2xx JSON error value are NOT wrapped here — they
|
|
4644
|
-
* flow through {@link parseContractResponse}'s normal return, same as the
|
|
4645
|
-
* session `execute` path.
|
|
4646
|
-
*
|
|
4647
|
-
* The message is always one of a small set of fixed, generic strings — it
|
|
4648
|
-
* NEVER contains the raw api key, the response body text, or the
|
|
4649
|
-
* underlying network error's message: a server (or a
|
|
4650
|
-
* misbehaving intermediary) that echoes the key or other secrets back in
|
|
4651
|
-
* an error body must not be able to leak them through this error's
|
|
4652
|
-
* message.
|
|
4653
|
-
*/
|
|
4654
|
-
declare class InvokeError extends T3nError {
|
|
4655
|
-
readonly status?: number | undefined;
|
|
4656
|
-
constructor(message: string, status?: number | undefined);
|
|
4657
|
-
}
|
|
4658
|
-
/**
|
|
4659
|
-
* Execute a `z:` contract as an agent, authenticating with an API key or an
|
|
4660
|
-
* OAuth bearer ({@link StatelessCredential}) — one request, no handshake, no
|
|
4661
|
-
* session.
|
|
4662
|
-
*
|
|
4663
|
-
* @param opts - baseUrl, apiKey, and the wire request to execute
|
|
4664
|
-
* @param schema - optional validator applied to the decoded result (e.g. a
|
|
4665
|
-
* zod schema); anything exposing `.parse(value)` is accepted, same as
|
|
4666
|
-
* {@link T3nClient.executeAndDecode}
|
|
4667
|
-
* @returns the contract's decoded result, typed as `T`
|
|
4668
|
-
* @throws {InvokeError} if `baseUrl` is insecure, on a network
|
|
4669
|
-
* failure/timeout, or on a non-2xx response
|
|
4670
|
-
* @throws {ContractResponseError} if the node returns a 2xx with a body
|
|
4671
|
-
* that is not valid JSON
|
|
4672
|
-
*/
|
|
4673
|
-
declare function invoke<T = unknown>(opts: InvokeOptions, schema?: ContractResponseSchema<T>): Promise<T>;
|
|
4674
|
-
/**
|
|
4675
|
-
* Transport options shared by the keyed discovery reads. Mirrors the transport
|
|
4676
|
-
* half of {@link InvokeOptions} (no `request`; the operation params are the
|
|
4677
|
-
* second argument of each read). Same HTTPS + secret-hygiene rules as `invoke`.
|
|
4678
|
-
*/
|
|
4679
|
-
type DiscoverOptions = StatelessCredential & {
|
|
4680
|
-
/**
|
|
4681
|
-
* RPC base URL of the T3n node, e.g. `https://node.example.com`. Must be
|
|
4682
|
-
* `https:` unless the host is a local-dev loopback — see
|
|
4683
|
-
* {@link InvokeOptions.baseUrl}.
|
|
4684
|
-
*/
|
|
4685
|
-
baseUrl: string;
|
|
4686
|
-
/** Fetch timeout in ms. Defaults to 30s, matching {@link invoke}. */
|
|
4687
|
-
timeoutMs?: number;
|
|
4688
|
-
};
|
|
4689
|
-
/**
|
|
4690
|
-
* `whoami` — resolve the DID the relayed credential maps to. The node never
|
|
4691
|
-
* trusts a caller-supplied DID; this is the relay's sole DID source.
|
|
4692
|
-
*
|
|
4693
|
-
* @throws {InvokeError} if `baseUrl` is insecure, on a network failure/timeout,
|
|
4694
|
-
* or on a non-2xx response
|
|
4695
|
-
*/
|
|
4696
|
-
declare function discoverWhoami(opts: DiscoverOptions): Promise<WhoamiResult>;
|
|
4697
|
-
/**
|
|
4698
|
-
* `contracts.list` — the keyed counterpart of {@link T3nClient.listContracts}.
|
|
4699
|
-
* Absent `params` (`{}`) lists the curated `core` contracts; `org` / `self`
|
|
4700
|
-
* scopes are discovery-grant gated server-side (R5 non-disclosive empty page).
|
|
4701
|
-
*
|
|
4702
|
-
* @throws {InvokeError} — see {@link discoverWhoami}
|
|
4703
|
-
*/
|
|
4704
|
-
declare function discoverListContracts(opts: DiscoverOptions, params?: ListContractsParams): Promise<ListContractsResult>;
|
|
4705
|
-
/**
|
|
4706
|
-
* `delegation.check` — the keyed counterpart of
|
|
4707
|
-
* {@link T3nClient.checkDelegation}. Returns the `member_delegation ∩ org_delegation`
|
|
4708
|
-
* verdict for the acting agent (as itself, or for `params.pii_did`).
|
|
4709
|
-
*
|
|
4710
|
-
* @throws {InvokeError} — see {@link discoverWhoami}
|
|
4711
|
-
*/
|
|
4712
|
-
declare function discoverCheckDelegation(opts: DiscoverOptions, params: GrantCheckParams): Promise<GrantCheckResult>;
|
|
4713
|
-
/**
|
|
4714
|
-
* `describe.contract` — the authority-gated keyed describe read. Returns
|
|
4715
|
-
* `{ contract, version, descriptor }`: the resolved dispatch `version` (the
|
|
4716
|
-
* `scriptVersion` an {@link invoke} call needs) alongside the contract's full
|
|
4717
|
-
* descriptor document. Unlike the session/stdio public descriptor GET, the relay
|
|
4718
|
-
* path is membership-gated on the contract's owning org and returns a uniform
|
|
4719
|
-
* non-disclosive error for both "not found" and "not authorised"
|
|
4720
|
-
* (anti-enumeration).
|
|
4721
|
-
*
|
|
4722
|
-
* @throws {InvokeError} — see {@link discoverWhoami}
|
|
4723
|
-
*/
|
|
4724
|
-
declare function discoverDescribeContract(opts: DiscoverOptions, params: DescribeContractParams): Promise<DescribeContractResult>;
|
|
4725
|
-
/**
|
|
4726
|
-
* `describe.function` — the authority-gated keyed describe read for a single
|
|
4727
|
-
* function. Returns `{ contract, version, descriptor }` with `descriptor` the
|
|
4728
|
-
* projected function entry. Same gating as {@link discoverDescribeContract}.
|
|
4729
|
-
*
|
|
4730
|
-
* @throws {InvokeError} — see {@link discoverWhoami}
|
|
4731
|
-
*/
|
|
4732
|
-
declare function discoverDescribeFunction(opts: DiscoverOptions, params: DescribeFunctionParams): Promise<DescribeFunctionResult>;
|
|
4733
|
-
|
|
4734
|
-
/**
|
|
4735
|
-
* Token fixed-point units (USDT-style 6 decimals).
|
|
4736
|
-
*
|
|
4737
|
-
* As of `tee:*` metering v2, every token amount on the wire —
|
|
4738
|
-
* {@link BalanceRow}'s `available`/`reserved`, {@link UsageEntry.amount},
|
|
4739
|
-
* and `total_supply` — is denominated in **base units**, where
|
|
4740
|
-
* `1 T3N token = `{@link BASE_UNITS_PER_TOKEN}` base units`. The node
|
|
4741
|
-
* meters the *actual* fractional cost of each operation (pro-rata by
|
|
4742
|
-
* bytes / byte-seconds / fuel) down to `1e-6` token, so amounts are
|
|
4743
|
-
* raw integers in base units, NOT whole tokens.
|
|
4744
|
-
*
|
|
4745
|
-
* The wire fields are left as raw base units (no silent rescaling — that
|
|
4746
|
-
* would lose precision for large balances and surprise callers doing
|
|
4747
|
-
* arithmetic). Use {@link formatTokens} to render a human "tokens"
|
|
4748
|
-
* string and {@link toBaseUnits} to convert a token figure back.
|
|
4749
|
-
*
|
|
4750
|
-
* ⚠️ Breaking vs. the pre-decimals SDK: a balance that used to read `5`
|
|
4751
|
-
* (whole tokens) now reads `5_000_000` (base units). Multiply existing
|
|
4752
|
-
* display code through {@link formatTokens}.
|
|
4753
|
-
*/
|
|
4754
|
-
/** Decimal places in a T3N token (fixed; mirrors the node constant). */
|
|
4755
|
-
declare const TOKEN_DECIMALS = 6;
|
|
4756
|
-
/** Base units per whole T3N token — `10 ** TOKEN_DECIMALS`. */
|
|
4757
|
-
declare const BASE_UNITS_PER_TOKEN = 1000000;
|
|
4758
|
-
/**
|
|
4759
|
-
* Render a base-unit amount as a human-readable token string, e.g.
|
|
4760
|
-
* `25_920_000 → "25.92"`, `1_000_000 → "1"`, `4768 → "0.004768"`.
|
|
4761
|
-
*
|
|
4762
|
-
* Trailing-zero fraction digits are trimmed; an integer amount renders
|
|
4763
|
-
* with no decimal point. Accepts `number` or `bigint`; for balances
|
|
4764
|
-
* above `Number.MAX_SAFE_INTEGER` prefer passing a `bigint`.
|
|
4765
|
-
*/
|
|
4766
|
-
declare function formatTokens(baseUnits: number | bigint): string;
|
|
4767
|
-
/**
|
|
4768
|
-
* Convert a whole-or-fractional token figure to base units (rounded to
|
|
4769
|
-
* the nearest base unit). E.g. `25.92 → 25_920_000`, `1 → 1_000_000`.
|
|
4770
|
-
*/
|
|
4771
|
-
declare function toBaseUnits(tokens: number): number;
|
|
4772
|
-
|
|
4773
4124
|
/**
|
|
4774
4125
|
* OrgDataClient — typed wrapper over the existing authenticated
|
|
4775
4126
|
* `/api/rpc` + `action.execute` pipeline.
|
|
@@ -5115,7 +4466,7 @@ interface OrgDataClientOptions extends ExecuteOrgDataActionOptions {
|
|
|
5115
4466
|
* Extra headers added to every `/api/rpc` request the internal
|
|
5116
4467
|
* `T3nClient` makes. Mirrors `T3nClientConfig.headers` — needed when
|
|
5117
4468
|
* the node sits behind an edge policy that gates `/api/rpc` on a
|
|
5118
|
-
* header (e.g.
|
|
4469
|
+
* header (e.g. an access token the edge requires).
|
|
5119
4470
|
*/
|
|
5120
4471
|
headers?: Record<string, string>;
|
|
5121
4472
|
/**
|
|
@@ -5123,7 +4474,7 @@ interface OrgDataClientOptions extends ExecuteOrgDataActionOptions {
|
|
|
5123
4474
|
* attestation check (SP-003). Mirrors `T3nClientConfig.trustAnchor`:
|
|
5124
4475
|
* either a pinned {@link TrustAnchor} or the explicit
|
|
5125
4476
|
* `{ unsafe_trust_server: true }` opt-out. Required (no silent default)
|
|
5126
|
-
* so
|
|
4477
|
+
* so skipping verification is always a visible, grep-able choice —
|
|
5127
4478
|
* an authenticated ETH-key caller is still MITM-able on the ML-KEM key.
|
|
5128
4479
|
* Signed trust-anchor manifests are not published yet, so most callers
|
|
5129
4480
|
* pass `{ unsafe_trust_server: true }` today.
|
|
@@ -5282,8 +4633,8 @@ declare class OrgDataClient {
|
|
|
5282
4633
|
* (`admin`|`member`) (org-admin only). A human is a member absent from the
|
|
5283
4634
|
* agent registry — the exact complement of {@link listAgents}.
|
|
5284
4635
|
*
|
|
5285
|
-
* No profile PII (name/email) is returned; the roster is DID + role only
|
|
5286
|
-
*
|
|
4636
|
+
* No profile PII (name/email) is returned; the roster is DID + role only.
|
|
4637
|
+
* The response carries at most `limit` members plus an optional
|
|
5287
4638
|
* `next_cursor`; to enumerate every member, pass the returned `next_cursor`
|
|
5288
4639
|
* back as `cursor` until it is absent.
|
|
5289
4640
|
*/
|
|
@@ -5631,14 +4982,13 @@ declare class SessionOrgDataClient {
|
|
|
5631
4982
|
declare function createOrgDataClientFromSession(t3n: T3nClient, baseUrl: string): SessionOrgDataClient;
|
|
5632
4983
|
|
|
5633
4984
|
/**
|
|
5634
|
-
* Payroll request shapes
|
|
4985
|
+
* Payroll request shapes.
|
|
5635
4986
|
*
|
|
5636
4987
|
* Envelope-free authorisation removed the per-call delegation
|
|
5637
4988
|
* credential and envelope entirely: authority is now the standing on-chain
|
|
5638
4989
|
* `member_delegation` ∩ `org_delegation` intersection the host re-reads every call, and
|
|
5639
4990
|
* every payroll call emits the plain Direct wire variant (`{ request }`).
|
|
5640
|
-
* What remains here is the request body shape
|
|
5641
|
-
* the base64url / DID helpers callers still need.
|
|
4991
|
+
* What remains here is the request body shape and its canonical defaults.
|
|
5642
4992
|
*
|
|
5643
4993
|
* Wire conventions retained from the contract:
|
|
5644
4994
|
* - `batch_cap_cents` is emitted as a **JSON string** so JS Number
|
|
@@ -5681,62 +5031,6 @@ interface PayrollRunRequest {
|
|
|
5681
5031
|
type ComputePayrollRequest = Omit<PayrollRunRequest, "cycle_id">;
|
|
5682
5032
|
/** Default for `individual_disbursement_threshold_cents` — SGD 15,000. */
|
|
5683
5033
|
declare const DEFAULT_INDIVIDUAL_THRESHOLD_CENTS = 1500000n;
|
|
5684
|
-
declare function b64uEncode(input: Uint8Array): string;
|
|
5685
|
-
/**
|
|
5686
|
-
* Encode raw bytes to base64url-no-pad (RFC 4648 §5 with padding dropped).
|
|
5687
|
-
* The encoding the wire uses for binary fields.
|
|
5688
|
-
*/
|
|
5689
|
-
declare function b64uEncodeBytes(input: Uint8Array): string;
|
|
5690
|
-
/**
|
|
5691
|
-
* Decode a base64url-no-pad string. Strict — rejects standard-alphabet
|
|
5692
|
-
* `+` / `/` and any padding `=`.
|
|
5693
|
-
*/
|
|
5694
|
-
declare function b64uDecodeStrict(input: string): Uint8Array;
|
|
5695
|
-
/** @internal — preserved alias for in-tree callers. Prefer
|
|
5696
|
-
* {@link b64uEncodeBytes} / {@link b64uDecodeStrict}. */
|
|
5697
|
-
declare const _b64uEncode: typeof b64uEncode;
|
|
5698
|
-
/** Build a `did:t3n:<40-hex>` from raw 20 bytes. */
|
|
5699
|
-
declare function compactDidFromBytes(bytes: Uint8Array): string;
|
|
5700
|
-
|
|
5701
|
-
/** Closed-vocabulary serialisation annotations for a contract function's body. */
|
|
5702
|
-
interface WireBlock {
|
|
5703
|
-
/**
|
|
5704
|
-
* Field paths whose values are emitted as decimal strings. A path ending in
|
|
5705
|
-
* `.*` applies to every value of the named object/array (e.g.
|
|
5706
|
-
* `historical_baselines.*`).
|
|
5707
|
-
*/
|
|
5708
|
-
u64_as_string?: string[];
|
|
5709
|
-
/**
|
|
5710
|
-
* Byte fields carried as typed strings. The value is passed through when it
|
|
5711
|
-
* is already a string; a byte input (`Uint8Array` or a `number[]` of octets)
|
|
5712
|
-
* is encoded per its kind.
|
|
5713
|
-
*/
|
|
5714
|
-
string_encoded?: Record<string, StringEncoding>;
|
|
5715
|
-
}
|
|
5716
|
-
/** The closed set of `string_encoded` field kinds. */
|
|
5717
|
-
type StringEncoding = "did" | "address" | "hash";
|
|
5718
|
-
/**
|
|
5719
|
-
* Raised when a `wire` block asks for a projection the closed vocabulary cannot
|
|
5720
|
-
* express — an unrepresentable value for a declared field. It signals a
|
|
5721
|
-
* descriptor↔contract mismatch on the author's side, so callers surface it as a
|
|
5722
|
-
* terminal `unsupported_wire_encoding` rather than retrying.
|
|
5723
|
-
*/
|
|
5724
|
-
declare class WireEncodingError extends T3nError {
|
|
5725
|
-
readonly field: string;
|
|
5726
|
-
readonly encoding?: StringEncoding | undefined;
|
|
5727
|
-
constructor(message: string, field: string, encoding?: StringEncoding | undefined);
|
|
5728
|
-
}
|
|
5729
|
-
type JsonRecord = Record<string, unknown>;
|
|
5730
|
-
/**
|
|
5731
|
-
* Project `args` into the plain-args body a z-space contract deserialises,
|
|
5732
|
-
* applying the descriptor's `wire` annotations. Returns a new object; `args` is
|
|
5733
|
-
* never mutated. With no `wire` block the body is returned unchanged (the
|
|
5734
|
-
* JSON-plain path).
|
|
5735
|
-
*
|
|
5736
|
-
* @throws {WireEncodingError} when a declared field holds a value the
|
|
5737
|
-
* vocabulary cannot express.
|
|
5738
|
-
*/
|
|
5739
|
-
declare function requestToWire(args: JsonRecord, wire?: WireBlock): JsonRecord;
|
|
5740
5034
|
|
|
5741
5035
|
/**
|
|
5742
5036
|
* SessionUsageReportClient — typed wrapper over the authenticated
|
|
@@ -5952,16 +5246,6 @@ declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
|
5952
5246
|
*/
|
|
5953
5247
|
declare function assertShape<T>(value: unknown, guard: (v: unknown) => v is T, where: string): T;
|
|
5954
5248
|
|
|
5955
|
-
type Environment = "sandbox" | "testnet" | "production";
|
|
5956
|
-
declare const NODE_URLS: Record<Environment, string>;
|
|
5957
|
-
/**
|
|
5958
|
-
* Default environment for the public (@terminal3/t3n-sdk) artifact. External
|
|
5959
|
-
* consumers default to testnet (not production) — a safer default that the
|
|
5960
|
-
* interactive write-confirm and the SDK both honor. The wide/internal build
|
|
5961
|
-
* exports its own DEFAULT_ENVIRONMENT; the public rollup alias swaps this in.
|
|
5962
|
-
*/
|
|
5963
|
-
declare const DEFAULT_ENVIRONMENT: Environment;
|
|
5964
|
-
|
|
5965
5249
|
/**
|
|
5966
5250
|
* Configuration types for T3n SDK
|
|
5967
5251
|
*/
|
|
@@ -6845,5 +6129,5 @@ declare function tenantDidHex(tenantDid: string): string;
|
|
|
6845
6129
|
declare function validateTail(tail: string): string;
|
|
6846
6130
|
declare function canonicalTenantName(tenantDid: string, tail: string): string;
|
|
6847
6131
|
|
|
6848
|
-
export { AGENT_CARDS_SCOPE, AuthMethod,
|
|
6849
|
-
export type { ActivityCallerType, ActivityEntry, ActivityExportFile, ActivityExportStatus, ActivityOutcome, ActivityReport, AdminActionAuth, AdmitForOrgOptions, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentEgressEntry, AgentEgressGetResponse, AgentEgressRefInput, AgentSummary, AssignRolesInput, AuthInput, AuthoriseOAuthConnectionParams, BalanceRow, BoundGrant, ChargeReason, ClientAuth, ClientHandshake, ComputePayrollRequest, ConfigValidationResult, ContractAgentCountsInput, ContractAgentCountsResponse,
|
|
6132
|
+
export { AGENT_CARDS_SCOPE, AuthMethod, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, OrgDataClient, SessionOrgDataClient, SessionStatus, SessionUsageReportClient, T3nClient, TERMINAL_KYC_STATUSES, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, Z_PAYROLL_AUDIT_READ_FUNCTIONS, Z_PAYROLL_RUN_FUNCTIONS, assertShape, buildSecretWriteArgs, bytesToString, canonicalTenantName, clearKeyCache, clearManifestVersionFloor, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, deriveAgentCardEntryId, detectQuoteVendor, eth_get_address, fanOutGrant, fetchDkgAttestation, fetchMlKemPublicKey, fetchSevSnpCollateral, fetchTrustedManifest, generateRandomString, generateUUID, getContractVersion, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, isAgentCardResponse, isAgentEgressGetResponse, isContractAgentCountsResponse, isDataGetResponse, isDataListResponse, isListAgentsResponse, isListHumanMembersResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractDelegation, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isRoleAssignmentsResponse, isRoleGetResponse, isSecretListResponse, isSecretRecord, isSecretView, isUnsafeTrustServer, loadConfig, loadWasmComponent, manifestToTrustAnchor, maskKeyMaterial, mergeDiscoverDids, mergeGrants, metamask_get_address, metamask_sign, parseMemberDelegationDoc, readOnlyScopes, redactSecrets, redactSecretsFromJson, resolveTrustAnchor, setEnvironment, setGlobalLogLevel, setNodeUrl, sevSnpVcekUrl, stringToBytes, tenantDidHex, validateConfig, validateTail, verifyDkgAttestation, verifyManifestSignature, verifySevSnpReport, verifyTdxQuote };
|
|
6133
|
+
export type { ActivityCallerType, ActivityEntry, ActivityExportFile, ActivityExportStatus, ActivityOutcome, ActivityReport, AdminActionAuth, AdmitForOrgOptions, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentEgressEntry, AgentEgressGetResponse, AgentEgressRefInput, AgentSummary, AssignRolesInput, AuthInput, AuthoriseOAuthConnectionParams, BalanceRow, BoundGrant, ChargeReason, ClientAuth, ClientHandshake, ComputePayrollRequest, ConfigValidationResult, ContractAgentCountsInput, ContractAgentCountsResponse, ContractDescriptorFacets, ContractExecuteInput, ContractLifecycleStatus, ContractListDetailedOptions, ContractListDetailedPage, ContractPublishInput, ContractRegisterResult, ContractSetDescriptorInput, ContractUnsetDescriptorInput, ContractUnsetDescriptorResult, CreateDelegatedAgentParams, CreateHarnessAgentParams, CreatePolicyInput, CreateT3nAgentParams, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegatedAgent, DelegatedAgentKind, DeleteDataInput, DeleteScopeInput, DescribeOAuthClientParams, DetailedContract, Did, DidKind, Direction, DkgAttestation, DkgVerifyResult, DrainContractAgentCountsInput, EmailOtpAuthInput, EmailOtpCredentials, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, ExportActivityLogOptions, FetchTrustedManifestOptions, GetActivityLogOptions, GetUsageOptions, GranteeInput, GrantsMergeResult, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, HumanMember, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListAgentsInput, ListAgentsResponse, ListHumanMembersInput, ListHumanMembersResponse, ListedDelegatedAgent, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MemberDelegationDoc, MemberRole, MutationResponse, OAuthAuthorisation, OAuthClientDescription, OAuthClientKind, OAuthConnection, OAuthConnectionState, OAuthRedirectClass, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractDelegation, OrgDataActionWire, OrgDataClientOptions, OrgDelegationAddGrantsInput, OrgDelegationDeleteInput, OrgDelegationGetInput, OrgDelegationRemoveGrantsInput, OrgDelegationSetInput, OrgPolicyMeta, OrgPolicyView, OrgRemoveGrantTarget, OrgRemoveMemberDelegationInput, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, PurgeOrgInput, QuoteVerifyResult, ReaderSet, RemoveTarget, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, ScopeAccessVerb, SdkConfig, SecretKind, SecretListInput, SecretListResponse, SecretNameInput, SecretRecord, SecretSetValueInput, SecretView, SecretWriteInput, SessionCrypto, SessionId, SetAgentEgressInput, SetDefaultQuotasOptions, SetRoleInput, SetWritersInput, SevSnpCollateral, SevSnpVerifyResult, SignedTrustManifest, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantContractUnsetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, TrustAnchorSource, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UpdateQuotasOptions, UsageEntry, UsagePage, UsageReportSignature, UserInputProfile, UserUpsertErrorKind, Validity, VcekUrlResult, WasmComponent, WasmNextResult, WireScope, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
|