@terminal3/t3n-sdk 2.5.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +263 -44
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/delegation.d.ts +58 -6
- package/dist/src/client/org-data.d.ts +117 -49
- package/dist/src/index.d.ts +6 -4
- package/dist/src/types/org-data.d.ts +38 -5
- package/dist/src/utils/errors.d.ts +21 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/shape.d.ts +30 -0
- package/package.json +2 -10
package/dist/index.d.ts
CHANGED
|
@@ -355,6 +355,27 @@ declare class AuthenticationError extends T3nError {
|
|
|
355
355
|
declare class HandshakeError extends T3nError {
|
|
356
356
|
constructor(message: string);
|
|
357
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Error thrown when a session-authenticated SDK client detects that the
|
|
360
|
+
* caller-owned session is no longer usable and the caller must
|
|
361
|
+
* re-authenticate before the call can succeed.
|
|
362
|
+
*
|
|
363
|
+
* Unlike {@link OrgDataClient} (which owns its ETH-secret-driven session
|
|
364
|
+
* and silently rebuilds it on expiry), {@link SessionOrgDataClient} is
|
|
365
|
+
* handed a caller-owned `T3nClient` whose session is bound to an
|
|
366
|
+
* interactive flow (typically SIWE). The SDK can't re-authenticate
|
|
367
|
+
* non-interactively, so on the same wire patterns that the
|
|
368
|
+
* self-owned client recovers from, the session-bound client translates
|
|
369
|
+
* the underlying error into this class and rethrows. The original error
|
|
370
|
+
* is preserved on the native ES2022 `cause` property.
|
|
371
|
+
*
|
|
372
|
+
* Callers branch on `instanceof SessionExpiredError` to route the user
|
|
373
|
+
* to a re-auth UX (e.g. SIWE modal / login redirect) rather than
|
|
374
|
+
* parsing the message of a raw {@link RpcError}.
|
|
375
|
+
*/
|
|
376
|
+
declare class SessionExpiredError extends T3nError {
|
|
377
|
+
constructor(cause: unknown);
|
|
378
|
+
}
|
|
358
379
|
/**
|
|
359
380
|
* Error thrown during RPC communication.
|
|
360
381
|
*
|
|
@@ -607,6 +628,13 @@ declare class UserUpsertError extends T3nError {
|
|
|
607
628
|
* Plain TypeScript interfaces (no zod) — the SDK does not use a
|
|
608
629
|
* validation library for domain types; see the existing `types/` files.
|
|
609
630
|
*
|
|
631
|
+
* Each response type below is paired with a shallow runtime predicate
|
|
632
|
+
* (`isMutationResponse`, `isOrgPolicyMeta`, etc.) so the org-data client
|
|
633
|
+
* can `assertShape` the decoded payload before returning to callers.
|
|
634
|
+
* Predicates check the top-level structure only; nested elements
|
|
635
|
+
* (e.g. each `UserGrant` inside `OrgContractGrants.grants`) are not
|
|
636
|
+
* deeply validated — see `utils/shape.ts` for the rationale.
|
|
637
|
+
*
|
|
610
638
|
* Reference: `org-data-types/src/lib.rs` and
|
|
611
639
|
* `tee-contract-org-data/src/org_data.rs`.
|
|
612
640
|
*/
|
|
@@ -645,6 +673,8 @@ interface OrgPolicyMeta {
|
|
|
645
673
|
/** Unix timestamp (secs) of the most recent policy update. */
|
|
646
674
|
updated_at_secs: number;
|
|
647
675
|
}
|
|
676
|
+
/** Shallow runtime guard for {@link OrgPolicyMeta}. */
|
|
677
|
+
declare function isOrgPolicyMeta(value: unknown): value is OrgPolicyMeta;
|
|
648
678
|
type EmploymentStatus = "Active" | "Terminated";
|
|
649
679
|
/** Singapore CPF residency categories. */
|
|
650
680
|
type ResidencyCategory = "Citizen" | "Pr1" | "Pr2" | "PrThreePlus" | "Foreigner";
|
|
@@ -696,6 +726,15 @@ interface MutationResponse {
|
|
|
696
726
|
deleted_entries?: number;
|
|
697
727
|
tx_hash: string | null;
|
|
698
728
|
}
|
|
729
|
+
/**
|
|
730
|
+
* Shallow runtime guard for {@link MutationResponse}.
|
|
731
|
+
*
|
|
732
|
+
* Only the always-present fields are checked — `status` is mandatory on
|
|
733
|
+
* every mutation; `tx_hash` is non-optional but nullable. The optional
|
|
734
|
+
* fields (`entry_id`, `deleted`, `deleted_entries`) are not validated
|
|
735
|
+
* because their presence depends on which mutation ran.
|
|
736
|
+
*/
|
|
737
|
+
declare function isMutationResponse(value: unknown): value is MutationResponse;
|
|
699
738
|
/**
|
|
700
739
|
* Response type alias for org-writers-get.
|
|
701
740
|
*
|
|
@@ -705,6 +744,8 @@ interface MutationResponse {
|
|
|
705
744
|
interface OrgWriters {
|
|
706
745
|
writers: string[];
|
|
707
746
|
}
|
|
747
|
+
/** Shallow runtime guard for {@link OrgWriters}. */
|
|
748
|
+
declare function isOrgWriters(value: unknown): value is OrgWriters;
|
|
708
749
|
/**
|
|
709
750
|
* Response type alias for org-grants-get.
|
|
710
751
|
*
|
|
@@ -714,6 +755,15 @@ interface OrgContractGrants {
|
|
|
714
755
|
contract_id: string;
|
|
715
756
|
grants: UserGrant[];
|
|
716
757
|
}
|
|
758
|
+
/**
|
|
759
|
+
* Shallow runtime guard for {@link OrgContractGrants}.
|
|
760
|
+
*
|
|
761
|
+
* Validates the immediate envelope (`contract_id: string`, `grants:
|
|
762
|
+
* array`) without recursing into each `UserGrant`. The Rust contract
|
|
763
|
+
* is the source of truth for grant element shape; widening the predicate
|
|
764
|
+
* here would create maintenance churn against benign field additions.
|
|
765
|
+
*/
|
|
766
|
+
declare function isOrgContractGrants(value: unknown): value is OrgContractGrants;
|
|
717
767
|
/** Response for `org-data-list`. */
|
|
718
768
|
interface DataListResponse {
|
|
719
769
|
/** Hex-encoded entry IDs for this page. */
|
|
@@ -723,24 +773,28 @@ interface DataListResponse {
|
|
|
723
773
|
/** Total number of entries in the scope (across all pages). */
|
|
724
774
|
total: number;
|
|
725
775
|
}
|
|
776
|
+
/** Shallow runtime guard for {@link DataListResponse}. */
|
|
777
|
+
declare function isDataListResponse(value: unknown): value is DataListResponse;
|
|
726
778
|
/** Response for `org-data-get`. */
|
|
727
779
|
interface DataGetResponse {
|
|
728
780
|
entry_id: string;
|
|
729
781
|
/** Hex-encoded raw payload bytes. */
|
|
730
782
|
payload_hex: string;
|
|
731
783
|
}
|
|
784
|
+
/** Shallow runtime guard for {@link DataGetResponse}. */
|
|
785
|
+
declare function isDataGetResponse(value: unknown): value is DataGetResponse;
|
|
732
786
|
/**
|
|
733
|
-
*
|
|
787
|
+
* Legacy direct-route org-data envelope shape retained for compatibility.
|
|
734
788
|
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
789
|
+
* This mirrors the removed `/api/user-contract/execute` body format from
|
|
790
|
+
* the transitional transport. New callers should use `OrgDataClient`,
|
|
791
|
+
* which now dispatches through authenticated `/api/rpc` +
|
|
792
|
+
* `action.execute` instead.
|
|
738
793
|
*/
|
|
739
794
|
interface OrgDataActionWire {
|
|
740
795
|
nonce: string;
|
|
741
796
|
user_did: string;
|
|
742
797
|
authenticator_id: string;
|
|
743
|
-
org_did: string;
|
|
744
798
|
contract_id: string;
|
|
745
799
|
function: string;
|
|
746
800
|
args_hash: string;
|
|
@@ -1735,12 +1789,41 @@ interface PayrollRunRequest {
|
|
|
1735
1789
|
batch_cap_cents: bigint;
|
|
1736
1790
|
/** `employee_id` → previous-cycle baseline net disbursement, cents (decimal string). */
|
|
1737
1791
|
historical_baselines: Record<string, string>;
|
|
1792
|
+
/**
|
|
1793
|
+
* Per-employee disbursement flag threshold, in cents. Mirrors
|
|
1794
|
+
* `PayrollRunRequest::individual_disbursement_threshold_cents` on the Rust
|
|
1795
|
+
* side. When absent the Rust contract applies its own default (SGD 15,000;
|
|
1796
|
+
* `DEFAULT_INDIVIDUAL_THRESHOLD_CENTS`). When present, the value is
|
|
1797
|
+
* included in the wire shape and participates in the request hash.
|
|
1798
|
+
*/
|
|
1799
|
+
individual_disbursement_threshold_cents?: bigint;
|
|
1738
1800
|
}
|
|
1739
|
-
/**
|
|
1740
|
-
|
|
1801
|
+
/** Default for `individual_disbursement_threshold_cents` — SGD 15,000. */
|
|
1802
|
+
declare const DEFAULT_INDIVIDUAL_THRESHOLD_CENTS = 1500000n;
|
|
1803
|
+
/** Delegated invocation: the agent acts on behalf of a user. */
|
|
1804
|
+
interface PayrollInvocationDelegated {
|
|
1741
1805
|
envelope: DelegationEnvelope;
|
|
1742
1806
|
request: PayrollRunRequest;
|
|
1743
1807
|
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Direct invocation: the agent acts on its own behalf. No delegation
|
|
1810
|
+
* envelope is included. The principal DID is resolved by the service layer
|
|
1811
|
+
* from `DynamicContext.authenticated_did`; authorisation falls through to
|
|
1812
|
+
* `OrgContractGrants[org || "tee:payroll"]` for the agent's own DID.
|
|
1813
|
+
*
|
|
1814
|
+
* Wire shape is `{ request }` — no `envelope` field and no
|
|
1815
|
+
* `authenticated_did` field. The contract's entry-point handler injects
|
|
1816
|
+
* `authenticated_did` from `GenericInput.context` before calling `verify`.
|
|
1817
|
+
*/
|
|
1818
|
+
interface PayrollInvocationDirect {
|
|
1819
|
+
request: PayrollRunRequest;
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Union of the two invocation variants. The serde-untagged enum on the
|
|
1823
|
+
* contract side disambiguates by presence of `envelope` — delegated calls
|
|
1824
|
+
* carry `{ envelope, request }`, direct calls carry `{ request }` only.
|
|
1825
|
+
*/
|
|
1826
|
+
type PayrollInvocation = PayrollInvocationDelegated | PayrollInvocationDirect;
|
|
1744
1827
|
/** Response from `tee:delegation.sign`. */
|
|
1745
1828
|
interface SignDelegationResponse {
|
|
1746
1829
|
credential_jcs: Uint8Array;
|
|
@@ -1910,39 +1993,53 @@ interface BuildPayrollInvocationOpts {
|
|
|
1910
1993
|
agentSecret: Uint8Array;
|
|
1911
1994
|
}
|
|
1912
1995
|
/**
|
|
1913
|
-
* Assemble a
|
|
1914
|
-
* given a user-signed credential and a per-call agent secret.
|
|
1915
|
-
* `request_hash` from the canonical request bytes and produces an
|
|
1996
|
+
* Assemble a delegated {@link PayrollInvocationDelegated} (envelope +
|
|
1997
|
+
* request) given a user-signed credential and a per-call agent secret.
|
|
1998
|
+
* Computes `request_hash` from the canonical request bytes and produces an
|
|
1916
1999
|
* `agent_sig` over `sha256(invocation_preimage)`.
|
|
2000
|
+
*
|
|
2001
|
+
* When `request.individual_disbursement_threshold_cents` is undefined this
|
|
2002
|
+
* function fills in {@link DEFAULT_INDIVIDUAL_THRESHOLD_CENTS} before
|
|
2003
|
+
* hashing so the SDK's hash matches the Rust contract's hash (the contract
|
|
2004
|
+
* applies the same default via `#[serde(default)]`).
|
|
1917
2005
|
*/
|
|
1918
|
-
declare function buildPayrollInvocation(opts: BuildPayrollInvocationOpts):
|
|
1919
|
-
|
|
2006
|
+
declare function buildPayrollInvocation(opts: BuildPayrollInvocationOpts): PayrollInvocationDelegated;
|
|
2007
|
+
/** Options for {@link buildPayrollDirectInvocation}. */
|
|
2008
|
+
interface BuildPayrollDirectInvocationOpts {
|
|
2009
|
+
request: PayrollRunRequest;
|
|
2010
|
+
}
|
|
1920
2011
|
/**
|
|
1921
|
-
*
|
|
1922
|
-
*
|
|
1923
|
-
*
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
* 1. `POST /api/org-data/nonce` — fetch a single-use replay nonce.
|
|
1927
|
-
* 2. `POST /api/org-data/execute` — submit a signed envelope whose
|
|
1928
|
-
* EIP-191 signature covers the canonical JSON of the eight
|
|
1929
|
-
* `SignableEnvelope` fields, in the exact field-declaration order
|
|
1930
|
-
* used by the Rust struct (see `org_data.rs` lines 104–117).
|
|
2012
|
+
* Assemble a direct {@link PayrollInvocationDirect} — no delegation
|
|
2013
|
+
* envelope. The caller supplies only the request body; the contract
|
|
2014
|
+
* entry-point resolves the principal DID from
|
|
2015
|
+
* `DynamicContext.authenticated_did` at runtime.
|
|
1931
2016
|
*
|
|
1932
|
-
*
|
|
1933
|
-
*
|
|
2017
|
+
* Callers in direct mode must hold a grant in
|
|
2018
|
+
* `OrgContractGrants[org || "tee:payroll"]` under their own DID.
|
|
1934
2019
|
*
|
|
1935
|
-
* `
|
|
1936
|
-
*
|
|
2020
|
+
* When `request.individual_disbursement_threshold_cents` is undefined this
|
|
2021
|
+
* function fills in {@link DEFAULT_INDIVIDUAL_THRESHOLD_CENTS} so the wire
|
|
2022
|
+
* shape matches the Rust contract's `#[serde(default)]` canonicalisation.
|
|
1937
2023
|
*/
|
|
2024
|
+
declare function buildPayrollDirectInvocation(opts: BuildPayrollDirectInvocationOpts): PayrollInvocationDirect;
|
|
1938
2025
|
|
|
1939
2026
|
/**
|
|
1940
|
-
*
|
|
2027
|
+
* OrgDataClient — typed wrapper over the existing authenticated
|
|
2028
|
+
* `/api/rpc` + `action.execute` pipeline.
|
|
2029
|
+
*
|
|
2030
|
+
* Unlike the removed direct `/api/user-contract/*` transport, this
|
|
2031
|
+
* client reuses Trinity's normal session-backed ETH auth flow:
|
|
2032
|
+
*
|
|
2033
|
+
* 1. `auth.handshake`
|
|
2034
|
+
* 2. `auth.authenticate`
|
|
2035
|
+
* 3. `action.execute`
|
|
2036
|
+
*
|
|
2037
|
+
* The class keeps its public constructor stable for callers that
|
|
2038
|
+
* already have an ETH secret key and expected DID, but internally it
|
|
2039
|
+
* owns a lazily-authenticated `T3nClient` instance rather than
|
|
2040
|
+
* constructing one-shot signed HTTP envelopes per call.
|
|
1941
2041
|
*/
|
|
1942
|
-
|
|
1943
|
-
/** Envelope TTL in seconds. Defaults to {@link DEFAULT_ENVELOPE_TTL_SECS}. */
|
|
1944
|
-
ttlSecs?: number;
|
|
1945
|
-
}
|
|
2042
|
+
|
|
1946
2043
|
interface CreatePolicyInput {
|
|
1947
2044
|
orgDid: string;
|
|
1948
2045
|
initialAdminDid: string;
|
|
@@ -2009,31 +2106,46 @@ interface DataGetInput {
|
|
|
2009
2106
|
/** Hex-encoded entry ID (32 hex chars). */
|
|
2010
2107
|
entryId: string;
|
|
2011
2108
|
}
|
|
2109
|
+
interface ExecuteOrgDataActionOptions {
|
|
2110
|
+
/**
|
|
2111
|
+
* Deprecated. The direct signed-envelope transport used this as the
|
|
2112
|
+
* envelope expiry window; the session-backed RPC path ignores it.
|
|
2113
|
+
*/
|
|
2114
|
+
ttlSecs?: number;
|
|
2115
|
+
}
|
|
2012
2116
|
/**
|
|
2013
2117
|
* Options used when constructing an {@link OrgDataClient}.
|
|
2014
2118
|
*/
|
|
2015
|
-
interface OrgDataClientOptions {
|
|
2016
|
-
/**
|
|
2017
|
-
|
|
2119
|
+
interface OrgDataClientOptions extends ExecuteOrgDataActionOptions {
|
|
2120
|
+
/** Optional preloaded WASM component for tests or shared callers. */
|
|
2121
|
+
wasmComponent?: WasmComponent;
|
|
2122
|
+
/** Optional transport override, primarily for tests. */
|
|
2123
|
+
transport?: Transport;
|
|
2124
|
+
/**
|
|
2125
|
+
* Optional handler overrides. If `EthSign` is omitted, the client
|
|
2126
|
+
* uses the supplied `ethSecret` to satisfy Trinity's existing ETH
|
|
2127
|
+
* auth challenge flow automatically.
|
|
2128
|
+
*/
|
|
2129
|
+
handlers?: GuestToHostHandlers;
|
|
2018
2130
|
}
|
|
2019
2131
|
/**
|
|
2020
|
-
* Client for
|
|
2132
|
+
* Client for session-authenticated org-data contract execution.
|
|
2021
2133
|
*
|
|
2022
2134
|
* Constructed with the node's base URL, the caller's 32-byte ETH secret
|
|
2023
|
-
* key, and the caller's DID (`did:t3n:<40-hex>`).
|
|
2024
|
-
*
|
|
2025
|
-
* and
|
|
2026
|
-
*
|
|
2027
|
-
* The signing key must be the same key registered as an authenticator
|
|
2028
|
-
* (`eth:0x<addr>`) for `userDid` in the DID registry — the service
|
|
2029
|
-
* verifies this binding before dispatching any contract call.
|
|
2135
|
+
* key, and the caller's DID (`did:t3n:<40-hex>`). The first method call
|
|
2136
|
+
* lazily creates a `T3nClient`, completes ETH session auth, verifies that
|
|
2137
|
+
* the authenticated DID matches `userDid`, and then reuses that session for
|
|
2138
|
+
* subsequent contract calls.
|
|
2030
2139
|
*/
|
|
2031
2140
|
declare class OrgDataClient {
|
|
2032
2141
|
private readonly baseUrl;
|
|
2033
2142
|
private readonly ethSecret;
|
|
2034
2143
|
private readonly userDid;
|
|
2035
2144
|
private readonly opts;
|
|
2145
|
+
private clientPromise;
|
|
2036
2146
|
constructor(baseUrl: string, ethSecret: Uint8Array, userDid: string, opts?: OrgDataClientOptions);
|
|
2147
|
+
private getAuthenticatedClient;
|
|
2148
|
+
private initialiseClient;
|
|
2037
2149
|
private call;
|
|
2038
2150
|
/**
|
|
2039
2151
|
* Initialise the data-tier policy for an existing organisation.
|
|
@@ -2100,6 +2212,82 @@ declare class OrgDataClient {
|
|
|
2100
2212
|
/** Retrieve a single data entry by entry ID (admin-only). */
|
|
2101
2213
|
dataGet(input: DataGetInput): Promise<DataGetResponse>;
|
|
2102
2214
|
}
|
|
2215
|
+
/**
|
|
2216
|
+
* Session-authenticated variant of {@link OrgDataClient}.
|
|
2217
|
+
*
|
|
2218
|
+
* Where `OrgDataClient` owns its own ETH-secret-driven session lifecycle,
|
|
2219
|
+
* `SessionOrgDataClient` accepts a caller-owned {@link T3nClient}. The
|
|
2220
|
+
* caller is responsible for completing `handshake()` and `authenticate()`
|
|
2221
|
+
* on that client (e.g. via the SIWE flow used by the orgs admin UI)
|
|
2222
|
+
* BEFORE invoking any method on this class — the constructor performs no
|
|
2223
|
+
* auth lifecycle of its own.
|
|
2224
|
+
*
|
|
2225
|
+
* Dispatches through `action.execute` against `tee:org-data/contracts`,
|
|
2226
|
+
* relying on the caller-owned `T3nClient` for the preceding
|
|
2227
|
+
* `auth.handshake` / `auth.authenticate` steps, so callers get the
|
|
2228
|
+
* identical method surface as `OrgDataClient` without needing a raw ETH
|
|
2229
|
+
* secret key.
|
|
2230
|
+
*
|
|
2231
|
+
* The runtime guard only catches the no-handshake case
|
|
2232
|
+
* (`t3n.getSessionId()` returns `null`); a client that has handshaken but
|
|
2233
|
+
* not authenticated will pass the guard and instead fail later with an
|
|
2234
|
+
* `RpcError` from `action.execute`. Authorisation is similarly the
|
|
2235
|
+
* caller's responsibility — the contract will refuse calls that aren't
|
|
2236
|
+
* backed by a recognised admin / writer DID, surfaced as the usual
|
|
2237
|
+
* `'CODE: detail'` refusal string.
|
|
2238
|
+
*/
|
|
2239
|
+
declare class SessionOrgDataClient {
|
|
2240
|
+
private readonly t3n;
|
|
2241
|
+
private readonly baseUrl;
|
|
2242
|
+
/**
|
|
2243
|
+
* @param t3n - a `T3nClient` that the caller has already driven through
|
|
2244
|
+
* `handshake()` and `authenticate()`. The constructor does not verify
|
|
2245
|
+
* this; the runtime guard on each method only catches the
|
|
2246
|
+
* no-handshake case (`getSessionId()` returns `null`). A
|
|
2247
|
+
* handshake-only-no-authenticate client will fail later with an
|
|
2248
|
+
* `RpcError` from `action.execute`.
|
|
2249
|
+
* @param baseUrl - node base URL (trailing slashes stripped). Mirrors
|
|
2250
|
+
* `OrgDataClient`'s signature for ergonomic parity; used only for the
|
|
2251
|
+
* `tee:org-data/contracts` version lookup and should match the node
|
|
2252
|
+
* the supplied `t3n` is bound to.
|
|
2253
|
+
*/
|
|
2254
|
+
constructor(t3n: T3nClient, baseUrl: string);
|
|
2255
|
+
private call;
|
|
2256
|
+
/** Mirrors {@link OrgDataClient.createPolicy}. */
|
|
2257
|
+
createPolicy(input: CreatePolicyInput): Promise<MutationResponse>;
|
|
2258
|
+
/** Mirrors {@link OrgDataClient.updateMeta}. */
|
|
2259
|
+
updateMeta(input: UpdateMetaInput): Promise<MutationResponse>;
|
|
2260
|
+
/** Mirrors {@link OrgDataClient.setWriters}. */
|
|
2261
|
+
setWriters(input: SetWritersInput): Promise<MutationResponse>;
|
|
2262
|
+
/** Mirrors {@link OrgDataClient.setGrants}. */
|
|
2263
|
+
setGrants(input: SetGrantsInput): Promise<MutationResponse>;
|
|
2264
|
+
/** Mirrors {@link OrgDataClient.deleteGrants}. */
|
|
2265
|
+
deleteGrants(input: DeleteGrantsInput): Promise<MutationResponse>;
|
|
2266
|
+
/** Mirrors {@link OrgDataClient.writeData}. */
|
|
2267
|
+
writeData(input: WriteDataInput): Promise<MutationResponse>;
|
|
2268
|
+
/** Mirrors {@link OrgDataClient.deleteData}. */
|
|
2269
|
+
deleteData(input: DeleteDataInput): Promise<MutationResponse>;
|
|
2270
|
+
/** Mirrors {@link OrgDataClient.deleteScope}. */
|
|
2271
|
+
deleteScope(input: DeleteScopeInput): Promise<MutationResponse>;
|
|
2272
|
+
/** Mirrors {@link OrgDataClient.policyGet}. */
|
|
2273
|
+
policyGet(input: PolicyGetInput): Promise<OrgPolicyMeta>;
|
|
2274
|
+
/** Mirrors {@link OrgDataClient.writersGet}. */
|
|
2275
|
+
writersGet(input: WritersGetInput): Promise<OrgWriters>;
|
|
2276
|
+
/** Mirrors {@link OrgDataClient.grantsGet}. */
|
|
2277
|
+
grantsGet(input: GrantsGetInput): Promise<OrgContractGrants>;
|
|
2278
|
+
/** Mirrors {@link OrgDataClient.dataList}. */
|
|
2279
|
+
dataList(input: DataListInput): Promise<DataListResponse>;
|
|
2280
|
+
/** Mirrors {@link OrgDataClient.dataGet}. */
|
|
2281
|
+
dataGet(input: DataGetInput): Promise<DataGetResponse>;
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Construct a {@link SessionOrgDataClient} from a caller-owned
|
|
2285
|
+
* {@link T3nClient} that has already been driven through `handshake()`
|
|
2286
|
+
* and `authenticate()`. Thin convenience wrapper — equivalent to
|
|
2287
|
+
* `new SessionOrgDataClient(t3n, baseUrl)`. See `SessionOrgDataClient`
|
|
2288
|
+
* for the full precondition contract and the runtime guard's limits.
|
|
2289
|
+
*/
|
|
2290
|
+
declare function createOrgDataClientFromSession(t3n: T3nClient, baseUrl: string): SessionOrgDataClient;
|
|
2103
2291
|
|
|
2104
2292
|
/**
|
|
2105
2293
|
* Cryptographic utilities for T3n SDK
|
|
@@ -2149,6 +2337,37 @@ declare function redactSecrets(value: unknown): unknown;
|
|
|
2149
2337
|
*/
|
|
2150
2338
|
declare function redactSecretsFromJson(jsonString: string): string;
|
|
2151
2339
|
|
|
2340
|
+
/**
|
|
2341
|
+
* Runtime shape guards for SDK response decoding.
|
|
2342
|
+
*
|
|
2343
|
+
* The contract layer is the source of truth for response shapes, but the
|
|
2344
|
+
* SDK's typed wrappers (`result as T`) are pure compile-time casts that
|
|
2345
|
+
* silently accept anything if a contract drifts or returns an unexpected
|
|
2346
|
+
* payload past the heuristic refusal-string check. `assertShape` lets the
|
|
2347
|
+
* outermost SDK boundary throw a deterministic, named error at the call
|
|
2348
|
+
* site rather than letting callers reach for `.admins` on `undefined`
|
|
2349
|
+
* deep in their own code.
|
|
2350
|
+
*
|
|
2351
|
+
* Predicates are intentionally shallow — they validate the immediate
|
|
2352
|
+
* top-level structure (object kind, presence/type of leading fields)
|
|
2353
|
+
* but do not deeply validate nested elements (e.g. each `UserGrant`
|
|
2354
|
+
* inside `OrgContractGrants.grants`). Deep validation would be brittle
|
|
2355
|
+
* against benign contract additions; shallow guards catch the failure
|
|
2356
|
+
* modes that actually surface as runtime crashes (null/string/missing
|
|
2357
|
+
* top-level field).
|
|
2358
|
+
*/
|
|
2359
|
+
/** Narrowing helper: value is a non-null object record. */
|
|
2360
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Run a type-predicate guard against `value` and throw a named error if
|
|
2363
|
+
* it fails. Returns the value typed as `T` on success.
|
|
2364
|
+
*
|
|
2365
|
+
* @param where - call-site identifier included in the thrown error
|
|
2366
|
+
* message (e.g. `'org-policy-get'`) so operators can grep logs back
|
|
2367
|
+
* to the offending RPC.
|
|
2368
|
+
*/
|
|
2369
|
+
declare function assertShape<T>(value: unknown, guard: (v: unknown) => v is T, where: string): T;
|
|
2370
|
+
|
|
2152
2371
|
/**
|
|
2153
2372
|
* Configuration types for T3n SDK
|
|
2154
2373
|
*/
|
|
@@ -2322,5 +2541,5 @@ declare function clearKeyCache(): void;
|
|
|
2322
2541
|
*/
|
|
2323
2542
|
declare function loadConfig(baseUrl?: string): SdkConfig;
|
|
2324
2543
|
|
|
2325
|
-
export { AGENT_PUBKEY_LEN, AuthMethod, AuthenticationError, ContractResponseError, DEFAULT_KYC_POLL_CADENCE, DELEGATION_CREDENTIAL_DOMAIN, DELEGATION_INVOCATION_DOMAIN, DelegationCustodialClient, ETH_SIG_LEN, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, NONCE_LEN, OrgDataClient, REQUEST_HASH_LEN, RpcError, SessionStateError, SessionStatus, T3nClient, T3nError, TERMINAL_KYC_STATUSES, UserUpsertError, VC_ID_LEN, WasmError, _b64uEncode, b64uDecodeStrict, b64uEncodeBytes, buildDelegationCredential, buildInvocationPreimage, buildPayrollInvocation, bytesToString, canonicaliseCredential, canonicaliseRequest, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createRandomHandler, decodeWasmErrorMessage, eip191Digest, ethRecoverEip191, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, loadConfig, loadWasmComponent, metamask_get_address, metamask_sign, parseContractResponse, redactSecrets, redactSecretsFromJson, requestHash, setEnvironment, setGlobalLogLevel, setNodeUrl, signAgentInvocation, signCredential, stringToBytes, validateConfig, validateCredentialBody, verifyDkgAttestation, verifyTdxQuote };
|
|
2326
|
-
export type { AgeBand, AuthInput, BuildDelegationCredentialOpts, BuildPayrollInvocationOpts, ClientAuth, ClientHandshake, ConfigValidationResult, ContractResponseSchema, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationCredential, DelegationCustodialClientOpts, DelegationEnvelope, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, DkgAttestation, DkgVerifyResult, EmployeeRecord, EmploymentStatus, Environment, EthAuthInput, ExecuteOrgDataActionOptions, ExpenseClaim, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, Logger, MutationResponse, OidcAuthInput, OidcCredentials, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollInvocation, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ResidencyCategory, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, SignCustodialResult, SignDelegationResponse, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, Transport, UpdateMetaInput, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WriteDataInput, WritersGetInput };
|
|
2544
|
+
export { AGENT_PUBKEY_LEN, AuthMethod, AuthenticationError, ContractResponseError, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, DELEGATION_CREDENTIAL_DOMAIN, DELEGATION_INVOCATION_DOMAIN, DelegationCustodialClient, ETH_SIG_LEN, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, NONCE_LEN, OrgDataClient, REQUEST_HASH_LEN, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, T3nClient, T3nError, TERMINAL_KYC_STATUSES, UserUpsertError, VC_ID_LEN, WasmError, _b64uEncode, assertShape, b64uDecodeStrict, b64uEncodeBytes, buildDelegationCredential, buildInvocationPreimage, buildPayrollDirectInvocation, buildPayrollInvocation, bytesToString, canonicaliseCredential, canonicaliseRequest, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, decodeWasmErrorMessage, eip191Digest, ethRecoverEip191, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgContractGrants, isOrgPolicyMeta, isOrgWriters, loadConfig, loadWasmComponent, metamask_get_address, metamask_sign, parseContractResponse, redactSecrets, redactSecretsFromJson, requestHash, setEnvironment, setGlobalLogLevel, setNodeUrl, signAgentInvocation, signCredential, stringToBytes, validateConfig, validateCredentialBody, verifyDkgAttestation, verifyTdxQuote };
|
|
2545
|
+
export type { AgeBand, AuthInput, BuildDelegationCredentialOpts, BuildPayrollDirectInvocationOpts, BuildPayrollInvocationOpts, ClientAuth, ClientHandshake, ConfigValidationResult, ContractResponseSchema, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationCredential, DelegationCustodialClientOpts, DelegationEnvelope, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, DkgAttestation, DkgVerifyResult, EmployeeRecord, EmploymentStatus, Environment, EthAuthInput, ExecuteOrgDataActionOptions, ExpenseClaim, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, Logger, MutationResponse, OidcAuthInput, OidcCredentials, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollInvocation, PayrollInvocationDelegated, PayrollInvocationDirect, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ResidencyCategory, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, SignCustodialResult, SignDelegationResponse, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, Transport, UpdateMetaInput, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WriteDataInput, WritersGetInput };
|