@terminal3/t3n-sdk 2.7.0 → 2.10.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.
- package/dist/index.d.ts +246 -9
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/actions.d.ts +1 -1
- package/dist/src/client/delegation.d.ts +58 -6
- package/dist/src/client/org-data.d.ts +76 -2
- package/dist/src/client/t3n-client.d.ts +5 -0
- package/dist/src/client/transport.d.ts +12 -0
- package/dist/src/index.d.ts +6 -4
- package/dist/src/types/auth.d.ts +8 -1
- package/dist/src/types/org-data.d.ts +33 -0
- 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 +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -301,12 +301,19 @@ interface OidcCredentials {
|
|
|
301
301
|
interface BaseAuthInput {
|
|
302
302
|
method: AuthMethod;
|
|
303
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Ethereum authentication options
|
|
306
|
+
*/
|
|
307
|
+
interface EthAuthOptions {
|
|
308
|
+
ethDerived?: boolean;
|
|
309
|
+
}
|
|
304
310
|
/**
|
|
305
311
|
* Ethereum authentication input
|
|
306
312
|
*/
|
|
307
313
|
interface EthAuthInput extends BaseAuthInput {
|
|
308
314
|
method: AuthMethod.Ethereum;
|
|
309
315
|
address: string;
|
|
316
|
+
ethDerived?: boolean;
|
|
310
317
|
}
|
|
311
318
|
/**
|
|
312
319
|
* OIDC authentication input
|
|
@@ -322,7 +329,7 @@ type AuthInput = EthAuthInput | OidcAuthInput;
|
|
|
322
329
|
/**
|
|
323
330
|
* Helper functions to create auth inputs
|
|
324
331
|
*/
|
|
325
|
-
declare function createEthAuthInput(address: string): EthAuthInput;
|
|
332
|
+
declare function createEthAuthInput(address: string, options?: EthAuthOptions): EthAuthInput;
|
|
326
333
|
declare function createOidcAuthInput(credentials: OidcCredentials): OidcAuthInput;
|
|
327
334
|
|
|
328
335
|
/**
|
|
@@ -355,6 +362,27 @@ declare class AuthenticationError extends T3nError {
|
|
|
355
362
|
declare class HandshakeError extends T3nError {
|
|
356
363
|
constructor(message: string);
|
|
357
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Error thrown when a session-authenticated SDK client detects that the
|
|
367
|
+
* caller-owned session is no longer usable and the caller must
|
|
368
|
+
* re-authenticate before the call can succeed.
|
|
369
|
+
*
|
|
370
|
+
* Unlike {@link OrgDataClient} (which owns its ETH-secret-driven session
|
|
371
|
+
* and silently rebuilds it on expiry), {@link SessionOrgDataClient} is
|
|
372
|
+
* handed a caller-owned `T3nClient` whose session is bound to an
|
|
373
|
+
* interactive flow (typically SIWE). The SDK can't re-authenticate
|
|
374
|
+
* non-interactively, so on the same wire patterns that the
|
|
375
|
+
* self-owned client recovers from, the session-bound client translates
|
|
376
|
+
* the underlying error into this class and rethrows. The original error
|
|
377
|
+
* is preserved on the native ES2022 `cause` property.
|
|
378
|
+
*
|
|
379
|
+
* Callers branch on `instanceof SessionExpiredError` to route the user
|
|
380
|
+
* to a re-auth UX (e.g. SIWE modal / login redirect) rather than
|
|
381
|
+
* parsing the message of a raw {@link RpcError}.
|
|
382
|
+
*/
|
|
383
|
+
declare class SessionExpiredError extends T3nError {
|
|
384
|
+
constructor(cause: unknown);
|
|
385
|
+
}
|
|
358
386
|
/**
|
|
359
387
|
* Error thrown during RPC communication.
|
|
360
388
|
*
|
|
@@ -607,6 +635,13 @@ declare class UserUpsertError extends T3nError {
|
|
|
607
635
|
* Plain TypeScript interfaces (no zod) — the SDK does not use a
|
|
608
636
|
* validation library for domain types; see the existing `types/` files.
|
|
609
637
|
*
|
|
638
|
+
* Each response type below is paired with a shallow runtime predicate
|
|
639
|
+
* (`isMutationResponse`, `isOrgPolicyMeta`, etc.) so the org-data client
|
|
640
|
+
* can `assertShape` the decoded payload before returning to callers.
|
|
641
|
+
* Predicates check the top-level structure only; nested elements
|
|
642
|
+
* (e.g. each `UserGrant` inside `OrgContractGrants.grants`) are not
|
|
643
|
+
* deeply validated — see `utils/shape.ts` for the rationale.
|
|
644
|
+
*
|
|
610
645
|
* Reference: `org-data-types/src/lib.rs` and
|
|
611
646
|
* `tee-contract-org-data/src/org_data.rs`.
|
|
612
647
|
*/
|
|
@@ -645,6 +680,8 @@ interface OrgPolicyMeta {
|
|
|
645
680
|
/** Unix timestamp (secs) of the most recent policy update. */
|
|
646
681
|
updated_at_secs: number;
|
|
647
682
|
}
|
|
683
|
+
/** Shallow runtime guard for {@link OrgPolicyMeta}. */
|
|
684
|
+
declare function isOrgPolicyMeta(value: unknown): value is OrgPolicyMeta;
|
|
648
685
|
type EmploymentStatus = "Active" | "Terminated";
|
|
649
686
|
/** Singapore CPF residency categories. */
|
|
650
687
|
type ResidencyCategory = "Citizen" | "Pr1" | "Pr2" | "PrThreePlus" | "Foreigner";
|
|
@@ -696,6 +733,15 @@ interface MutationResponse {
|
|
|
696
733
|
deleted_entries?: number;
|
|
697
734
|
tx_hash: string | null;
|
|
698
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Shallow runtime guard for {@link MutationResponse}.
|
|
738
|
+
*
|
|
739
|
+
* Only the always-present fields are checked — `status` is mandatory on
|
|
740
|
+
* every mutation; `tx_hash` is non-optional but nullable. The optional
|
|
741
|
+
* fields (`entry_id`, `deleted`, `deleted_entries`) are not validated
|
|
742
|
+
* because their presence depends on which mutation ran.
|
|
743
|
+
*/
|
|
744
|
+
declare function isMutationResponse(value: unknown): value is MutationResponse;
|
|
699
745
|
/**
|
|
700
746
|
* Response type alias for org-writers-get.
|
|
701
747
|
*
|
|
@@ -705,6 +751,8 @@ interface MutationResponse {
|
|
|
705
751
|
interface OrgWriters {
|
|
706
752
|
writers: string[];
|
|
707
753
|
}
|
|
754
|
+
/** Shallow runtime guard for {@link OrgWriters}. */
|
|
755
|
+
declare function isOrgWriters(value: unknown): value is OrgWriters;
|
|
708
756
|
/**
|
|
709
757
|
* Response type alias for org-grants-get.
|
|
710
758
|
*
|
|
@@ -714,6 +762,15 @@ interface OrgContractGrants {
|
|
|
714
762
|
contract_id: string;
|
|
715
763
|
grants: UserGrant[];
|
|
716
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* Shallow runtime guard for {@link OrgContractGrants}.
|
|
767
|
+
*
|
|
768
|
+
* Validates the immediate envelope (`contract_id: string`, `grants:
|
|
769
|
+
* array`) without recursing into each `UserGrant`. The Rust contract
|
|
770
|
+
* is the source of truth for grant element shape; widening the predicate
|
|
771
|
+
* here would create maintenance churn against benign field additions.
|
|
772
|
+
*/
|
|
773
|
+
declare function isOrgContractGrants(value: unknown): value is OrgContractGrants;
|
|
717
774
|
/** Response for `org-data-list`. */
|
|
718
775
|
interface DataListResponse {
|
|
719
776
|
/** Hex-encoded entry IDs for this page. */
|
|
@@ -723,12 +780,16 @@ interface DataListResponse {
|
|
|
723
780
|
/** Total number of entries in the scope (across all pages). */
|
|
724
781
|
total: number;
|
|
725
782
|
}
|
|
783
|
+
/** Shallow runtime guard for {@link DataListResponse}. */
|
|
784
|
+
declare function isDataListResponse(value: unknown): value is DataListResponse;
|
|
726
785
|
/** Response for `org-data-get`. */
|
|
727
786
|
interface DataGetResponse {
|
|
728
787
|
entry_id: string;
|
|
729
788
|
/** Hex-encoded raw payload bytes. */
|
|
730
789
|
payload_hex: string;
|
|
731
790
|
}
|
|
791
|
+
/** Shallow runtime guard for {@link DataGetResponse}. */
|
|
792
|
+
declare function isDataGetResponse(value: unknown): value is DataGetResponse;
|
|
732
793
|
/**
|
|
733
794
|
* Legacy direct-route org-data envelope shape retained for compatibility.
|
|
734
795
|
*
|
|
@@ -828,6 +889,10 @@ interface Transport {
|
|
|
828
889
|
* @returns Promise that resolves to the JSON-RPC response
|
|
829
890
|
*/
|
|
830
891
|
send(request: JsonRpcRequest, headers: Record<string, string>): Promise<JsonRpcResponse>;
|
|
892
|
+
/**
|
|
893
|
+
* Optionally send a JSON-RPC request with an attached binary blob.
|
|
894
|
+
*/
|
|
895
|
+
sendMultipart?(request: JsonRpcRequest, headers: Record<string, string>, blob: Blob): Promise<JsonRpcResponse>;
|
|
831
896
|
/**
|
|
832
897
|
* Optional accessor for the latest Set-Cookie header value.
|
|
833
898
|
* (Useful in Node.js demos/tests; browsers block HttpOnly cookies.)
|
|
@@ -850,6 +915,7 @@ declare class HttpTransport implements Transport {
|
|
|
850
915
|
getLastSetCookie(): string | null;
|
|
851
916
|
getLastResponseHeaders(): Record<string, string>;
|
|
852
917
|
send(request: JsonRpcRequest, headers: Record<string, string>): Promise<JsonRpcResponse>;
|
|
918
|
+
sendMultipart(request: JsonRpcRequest, headers: Record<string, string>, blob: Blob): Promise<JsonRpcResponse>;
|
|
853
919
|
}
|
|
854
920
|
/**
|
|
855
921
|
* Mock transport for testing
|
|
@@ -870,6 +936,7 @@ declare class MockTransport implements Transport {
|
|
|
870
936
|
private responseHeaders;
|
|
871
937
|
private lastResponseHeaders;
|
|
872
938
|
private requests;
|
|
939
|
+
private multipartRequests;
|
|
873
940
|
/**
|
|
874
941
|
* Mock a response for a specific method
|
|
875
942
|
*/
|
|
@@ -900,10 +967,16 @@ declare class MockTransport implements Transport {
|
|
|
900
967
|
request: JsonRpcRequest;
|
|
901
968
|
headers: Record<string, string>;
|
|
902
969
|
}>;
|
|
970
|
+
getMultipartRequests(): Array<{
|
|
971
|
+
request: JsonRpcRequest;
|
|
972
|
+
headers: Record<string, string>;
|
|
973
|
+
blob: Blob;
|
|
974
|
+
}>;
|
|
903
975
|
/**
|
|
904
976
|
* Clear all recorded requests
|
|
905
977
|
*/
|
|
906
978
|
clearRequests(): void;
|
|
979
|
+
sendMultipart(request: JsonRpcRequest, headers: Record<string, string>, blob: Blob): Promise<JsonRpcResponse>;
|
|
907
980
|
send(request: JsonRpcRequest, headers: Record<string, string>): Promise<JsonRpcResponse>;
|
|
908
981
|
}
|
|
909
982
|
|
|
@@ -1233,6 +1306,10 @@ declare class T3nClient {
|
|
|
1233
1306
|
* optionally validates it with a schema.
|
|
1234
1307
|
*/
|
|
1235
1308
|
execute(payload: unknown): Promise<string>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Execute an action with an attached binary blob using multipart RPC.
|
|
1311
|
+
*/
|
|
1312
|
+
executeWithBlob(payload: unknown, blob: Blob): Promise<string>;
|
|
1236
1313
|
/**
|
|
1237
1314
|
* Execute an action and JSON-decode the response.
|
|
1238
1315
|
*
|
|
@@ -1573,6 +1650,7 @@ declare class T3nClient {
|
|
|
1573
1650
|
* Send an RPC request with automatic encryption/decryption
|
|
1574
1651
|
*/
|
|
1575
1652
|
private sendRpcRequest;
|
|
1653
|
+
private sendMultipartRpcRequest;
|
|
1576
1654
|
/**
|
|
1577
1655
|
* Capture the server-minted `Session-Id` from the last handshake
|
|
1578
1656
|
* response headers (pentest M-1 / MAT-983). Validates shape so a
|
|
@@ -1735,12 +1813,41 @@ interface PayrollRunRequest {
|
|
|
1735
1813
|
batch_cap_cents: bigint;
|
|
1736
1814
|
/** `employee_id` → previous-cycle baseline net disbursement, cents (decimal string). */
|
|
1737
1815
|
historical_baselines: Record<string, string>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Per-employee disbursement flag threshold, in cents. Mirrors
|
|
1818
|
+
* `PayrollRunRequest::individual_disbursement_threshold_cents` on the Rust
|
|
1819
|
+
* side. When absent the Rust contract applies its own default (SGD 15,000;
|
|
1820
|
+
* `DEFAULT_INDIVIDUAL_THRESHOLD_CENTS`). When present, the value is
|
|
1821
|
+
* included in the wire shape and participates in the request hash.
|
|
1822
|
+
*/
|
|
1823
|
+
individual_disbursement_threshold_cents?: bigint;
|
|
1738
1824
|
}
|
|
1739
|
-
/**
|
|
1740
|
-
|
|
1825
|
+
/** Default for `individual_disbursement_threshold_cents` — SGD 15,000. */
|
|
1826
|
+
declare const DEFAULT_INDIVIDUAL_THRESHOLD_CENTS = 1500000n;
|
|
1827
|
+
/** Delegated invocation: the agent acts on behalf of a user. */
|
|
1828
|
+
interface PayrollInvocationDelegated {
|
|
1741
1829
|
envelope: DelegationEnvelope;
|
|
1742
1830
|
request: PayrollRunRequest;
|
|
1743
1831
|
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Direct invocation: the agent acts on its own behalf. No delegation
|
|
1834
|
+
* envelope is included. The principal DID is resolved by the service layer
|
|
1835
|
+
* from `DynamicContext.authenticated_did`; authorisation falls through to
|
|
1836
|
+
* `OrgContractGrants[org || "tee:payroll"]` for the agent's own DID.
|
|
1837
|
+
*
|
|
1838
|
+
* Wire shape is `{ request }` — no `envelope` field and no
|
|
1839
|
+
* `authenticated_did` field. The contract's entry-point handler injects
|
|
1840
|
+
* `authenticated_did` from `GenericInput.context` before calling `verify`.
|
|
1841
|
+
*/
|
|
1842
|
+
interface PayrollInvocationDirect {
|
|
1843
|
+
request: PayrollRunRequest;
|
|
1844
|
+
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Union of the two invocation variants. The serde-untagged enum on the
|
|
1847
|
+
* contract side disambiguates by presence of `envelope` — delegated calls
|
|
1848
|
+
* carry `{ envelope, request }`, direct calls carry `{ request }` only.
|
|
1849
|
+
*/
|
|
1850
|
+
type PayrollInvocation = PayrollInvocationDelegated | PayrollInvocationDirect;
|
|
1744
1851
|
/** Response from `tee:delegation.sign`. */
|
|
1745
1852
|
interface SignDelegationResponse {
|
|
1746
1853
|
credential_jcs: Uint8Array;
|
|
@@ -1910,12 +2017,35 @@ interface BuildPayrollInvocationOpts {
|
|
|
1910
2017
|
agentSecret: Uint8Array;
|
|
1911
2018
|
}
|
|
1912
2019
|
/**
|
|
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
|
|
2020
|
+
* Assemble a delegated {@link PayrollInvocationDelegated} (envelope +
|
|
2021
|
+
* request) given a user-signed credential and a per-call agent secret.
|
|
2022
|
+
* Computes `request_hash` from the canonical request bytes and produces an
|
|
1916
2023
|
* `agent_sig` over `sha256(invocation_preimage)`.
|
|
2024
|
+
*
|
|
2025
|
+
* When `request.individual_disbursement_threshold_cents` is undefined this
|
|
2026
|
+
* function fills in {@link DEFAULT_INDIVIDUAL_THRESHOLD_CENTS} before
|
|
2027
|
+
* hashing so the SDK's hash matches the Rust contract's hash (the contract
|
|
2028
|
+
* applies the same default via `#[serde(default)]`).
|
|
1917
2029
|
*/
|
|
1918
|
-
declare function buildPayrollInvocation(opts: BuildPayrollInvocationOpts):
|
|
2030
|
+
declare function buildPayrollInvocation(opts: BuildPayrollInvocationOpts): PayrollInvocationDelegated;
|
|
2031
|
+
/** Options for {@link buildPayrollDirectInvocation}. */
|
|
2032
|
+
interface BuildPayrollDirectInvocationOpts {
|
|
2033
|
+
request: PayrollRunRequest;
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
2036
|
+
* Assemble a direct {@link PayrollInvocationDirect} — no delegation
|
|
2037
|
+
* envelope. The caller supplies only the request body; the contract
|
|
2038
|
+
* entry-point resolves the principal DID from
|
|
2039
|
+
* `DynamicContext.authenticated_did` at runtime.
|
|
2040
|
+
*
|
|
2041
|
+
* Callers in direct mode must hold a grant in
|
|
2042
|
+
* `OrgContractGrants[org || "tee:payroll"]` under their own DID.
|
|
2043
|
+
*
|
|
2044
|
+
* When `request.individual_disbursement_threshold_cents` is undefined this
|
|
2045
|
+
* function fills in {@link DEFAULT_INDIVIDUAL_THRESHOLD_CENTS} so the wire
|
|
2046
|
+
* shape matches the Rust contract's `#[serde(default)]` canonicalisation.
|
|
2047
|
+
*/
|
|
2048
|
+
declare function buildPayrollDirectInvocation(opts: BuildPayrollDirectInvocationOpts): PayrollInvocationDirect;
|
|
1919
2049
|
|
|
1920
2050
|
/**
|
|
1921
2051
|
* OrgDataClient — typed wrapper over the existing authenticated
|
|
@@ -2106,6 +2236,82 @@ declare class OrgDataClient {
|
|
|
2106
2236
|
/** Retrieve a single data entry by entry ID (admin-only). */
|
|
2107
2237
|
dataGet(input: DataGetInput): Promise<DataGetResponse>;
|
|
2108
2238
|
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Session-authenticated variant of {@link OrgDataClient}.
|
|
2241
|
+
*
|
|
2242
|
+
* Where `OrgDataClient` owns its own ETH-secret-driven session lifecycle,
|
|
2243
|
+
* `SessionOrgDataClient` accepts a caller-owned {@link T3nClient}. The
|
|
2244
|
+
* caller is responsible for completing `handshake()` and `authenticate()`
|
|
2245
|
+
* on that client (e.g. via the SIWE flow used by the orgs admin UI)
|
|
2246
|
+
* BEFORE invoking any method on this class — the constructor performs no
|
|
2247
|
+
* auth lifecycle of its own.
|
|
2248
|
+
*
|
|
2249
|
+
* Dispatches through `action.execute` against `tee:org-data/contracts`,
|
|
2250
|
+
* relying on the caller-owned `T3nClient` for the preceding
|
|
2251
|
+
* `auth.handshake` / `auth.authenticate` steps, so callers get the
|
|
2252
|
+
* identical method surface as `OrgDataClient` without needing a raw ETH
|
|
2253
|
+
* secret key.
|
|
2254
|
+
*
|
|
2255
|
+
* The runtime guard only catches the no-handshake case
|
|
2256
|
+
* (`t3n.getSessionId()` returns `null`); a client that has handshaken but
|
|
2257
|
+
* not authenticated will pass the guard and instead fail later with an
|
|
2258
|
+
* `RpcError` from `action.execute`. Authorisation is similarly the
|
|
2259
|
+
* caller's responsibility — the contract will refuse calls that aren't
|
|
2260
|
+
* backed by a recognised admin / writer DID, surfaced as the usual
|
|
2261
|
+
* `'CODE: detail'` refusal string.
|
|
2262
|
+
*/
|
|
2263
|
+
declare class SessionOrgDataClient {
|
|
2264
|
+
private readonly t3n;
|
|
2265
|
+
private readonly baseUrl;
|
|
2266
|
+
/**
|
|
2267
|
+
* @param t3n - a `T3nClient` that the caller has already driven through
|
|
2268
|
+
* `handshake()` and `authenticate()`. The constructor does not verify
|
|
2269
|
+
* this; the runtime guard on each method only catches the
|
|
2270
|
+
* no-handshake case (`getSessionId()` returns `null`). A
|
|
2271
|
+
* handshake-only-no-authenticate client will fail later with an
|
|
2272
|
+
* `RpcError` from `action.execute`.
|
|
2273
|
+
* @param baseUrl - node base URL (trailing slashes stripped). Mirrors
|
|
2274
|
+
* `OrgDataClient`'s signature for ergonomic parity; used only for the
|
|
2275
|
+
* `tee:org-data/contracts` version lookup and should match the node
|
|
2276
|
+
* the supplied `t3n` is bound to.
|
|
2277
|
+
*/
|
|
2278
|
+
constructor(t3n: T3nClient, baseUrl: string);
|
|
2279
|
+
private call;
|
|
2280
|
+
/** Mirrors {@link OrgDataClient.createPolicy}. */
|
|
2281
|
+
createPolicy(input: CreatePolicyInput): Promise<MutationResponse>;
|
|
2282
|
+
/** Mirrors {@link OrgDataClient.updateMeta}. */
|
|
2283
|
+
updateMeta(input: UpdateMetaInput): Promise<MutationResponse>;
|
|
2284
|
+
/** Mirrors {@link OrgDataClient.setWriters}. */
|
|
2285
|
+
setWriters(input: SetWritersInput): Promise<MutationResponse>;
|
|
2286
|
+
/** Mirrors {@link OrgDataClient.setGrants}. */
|
|
2287
|
+
setGrants(input: SetGrantsInput): Promise<MutationResponse>;
|
|
2288
|
+
/** Mirrors {@link OrgDataClient.deleteGrants}. */
|
|
2289
|
+
deleteGrants(input: DeleteGrantsInput): Promise<MutationResponse>;
|
|
2290
|
+
/** Mirrors {@link OrgDataClient.writeData}. */
|
|
2291
|
+
writeData(input: WriteDataInput): Promise<MutationResponse>;
|
|
2292
|
+
/** Mirrors {@link OrgDataClient.deleteData}. */
|
|
2293
|
+
deleteData(input: DeleteDataInput): Promise<MutationResponse>;
|
|
2294
|
+
/** Mirrors {@link OrgDataClient.deleteScope}. */
|
|
2295
|
+
deleteScope(input: DeleteScopeInput): Promise<MutationResponse>;
|
|
2296
|
+
/** Mirrors {@link OrgDataClient.policyGet}. */
|
|
2297
|
+
policyGet(input: PolicyGetInput): Promise<OrgPolicyMeta>;
|
|
2298
|
+
/** Mirrors {@link OrgDataClient.writersGet}. */
|
|
2299
|
+
writersGet(input: WritersGetInput): Promise<OrgWriters>;
|
|
2300
|
+
/** Mirrors {@link OrgDataClient.grantsGet}. */
|
|
2301
|
+
grantsGet(input: GrantsGetInput): Promise<OrgContractGrants>;
|
|
2302
|
+
/** Mirrors {@link OrgDataClient.dataList}. */
|
|
2303
|
+
dataList(input: DataListInput): Promise<DataListResponse>;
|
|
2304
|
+
/** Mirrors {@link OrgDataClient.dataGet}. */
|
|
2305
|
+
dataGet(input: DataGetInput): Promise<DataGetResponse>;
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* Construct a {@link SessionOrgDataClient} from a caller-owned
|
|
2309
|
+
* {@link T3nClient} that has already been driven through `handshake()`
|
|
2310
|
+
* and `authenticate()`. Thin convenience wrapper — equivalent to
|
|
2311
|
+
* `new SessionOrgDataClient(t3n, baseUrl)`. See `SessionOrgDataClient`
|
|
2312
|
+
* for the full precondition contract and the runtime guard's limits.
|
|
2313
|
+
*/
|
|
2314
|
+
declare function createOrgDataClientFromSession(t3n: T3nClient, baseUrl: string): SessionOrgDataClient;
|
|
2109
2315
|
|
|
2110
2316
|
/**
|
|
2111
2317
|
* Cryptographic utilities for T3n SDK
|
|
@@ -2155,6 +2361,37 @@ declare function redactSecrets(value: unknown): unknown;
|
|
|
2155
2361
|
*/
|
|
2156
2362
|
declare function redactSecretsFromJson(jsonString: string): string;
|
|
2157
2363
|
|
|
2364
|
+
/**
|
|
2365
|
+
* Runtime shape guards for SDK response decoding.
|
|
2366
|
+
*
|
|
2367
|
+
* The contract layer is the source of truth for response shapes, but the
|
|
2368
|
+
* SDK's typed wrappers (`result as T`) are pure compile-time casts that
|
|
2369
|
+
* silently accept anything if a contract drifts or returns an unexpected
|
|
2370
|
+
* payload past the heuristic refusal-string check. `assertShape` lets the
|
|
2371
|
+
* outermost SDK boundary throw a deterministic, named error at the call
|
|
2372
|
+
* site rather than letting callers reach for `.admins` on `undefined`
|
|
2373
|
+
* deep in their own code.
|
|
2374
|
+
*
|
|
2375
|
+
* Predicates are intentionally shallow — they validate the immediate
|
|
2376
|
+
* top-level structure (object kind, presence/type of leading fields)
|
|
2377
|
+
* but do not deeply validate nested elements (e.g. each `UserGrant`
|
|
2378
|
+
* inside `OrgContractGrants.grants`). Deep validation would be brittle
|
|
2379
|
+
* against benign contract additions; shallow guards catch the failure
|
|
2380
|
+
* modes that actually surface as runtime crashes (null/string/missing
|
|
2381
|
+
* top-level field).
|
|
2382
|
+
*/
|
|
2383
|
+
/** Narrowing helper: value is a non-null object record. */
|
|
2384
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
2385
|
+
/**
|
|
2386
|
+
* Run a type-predicate guard against `value` and throw a named error if
|
|
2387
|
+
* it fails. Returns the value typed as `T` on success.
|
|
2388
|
+
*
|
|
2389
|
+
* @param where - call-site identifier included in the thrown error
|
|
2390
|
+
* message (e.g. `'org-policy-get'`) so operators can grep logs back
|
|
2391
|
+
* to the offending RPC.
|
|
2392
|
+
*/
|
|
2393
|
+
declare function assertShape<T>(value: unknown, guard: (v: unknown) => v is T, where: string): T;
|
|
2394
|
+
|
|
2158
2395
|
/**
|
|
2159
2396
|
* Configuration types for T3n SDK
|
|
2160
2397
|
*/
|
|
@@ -2328,5 +2565,5 @@ declare function clearKeyCache(): void;
|
|
|
2328
2565
|
*/
|
|
2329
2566
|
declare function loadConfig(baseUrl?: string): SdkConfig;
|
|
2330
2567
|
|
|
2331
|
-
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 };
|
|
2332
|
-
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 };
|
|
2568
|
+
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 };
|
|
2569
|
+
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 };
|