@terminal3/t3n-sdk 4.19.0 → 4.20.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 CHANGED
@@ -3898,6 +3898,116 @@ interface ConfigValidationResult {
3898
3898
  errors: string[];
3899
3899
  }
3900
3900
 
3901
+ /**
3902
+ * Operator-signed trust-manifest distribution.
3903
+ *
3904
+ * The SDK's attestation check (see `TrustAnchor`) needs a trusted source
3905
+ * for the expected cluster identity — the set of node peer IDs and the
3906
+ * allow-listed RTMR3 image measurements. Without a trusted source, every
3907
+ * caller has to hand-pin those values or fall back to
3908
+ * `{ unsafe_trust_server: true }`, which disables verification entirely.
3909
+ *
3910
+ * A trust manifest is a small JSON document published by the cluster
3911
+ * operator to a public URL (a GCS bucket) and signed with the operator's
3912
+ * secp256k1 key. Its public half is baked into the SDK per environment
3913
+ * (`OPERATOR_PUBLIC_KEYS`). `fetchTrustedManifest(env)` fetches the
3914
+ * manifest, verifies the signature against the pinned operator key, and
3915
+ * returns a {@link TrustAnchor} that plugs straight into
3916
+ * `T3nClientConfig.trustAnchor`.
3917
+ *
3918
+ * Trust model: the operator key is the root of trust. A network attacker
3919
+ * can serve any bytes at the manifest URL, but cannot forge a signature
3920
+ * for a manifest naming their own node identities/measurements without
3921
+ * the operator's private key. The manifest only ever *narrows* trust to
3922
+ * the real cluster — it never widens what the on-quote RTMR3 pinning and
3923
+ * peer-id set-equality already enforce inside the WASM verifier.
3924
+ */
3925
+
3926
+ /**
3927
+ * The signed payload an operator publishes. `signature` covers every
3928
+ * other field (see {@link canonicalManifestBytes}); it is excluded from
3929
+ * its own signing input.
3930
+ */
3931
+ interface SignedTrustManifest {
3932
+ /** Environment the manifest describes (e.g. `"production"`). */
3933
+ cluster: string;
3934
+ /** Monotonic manifest version; lets a client reject a rolled-back manifest. */
3935
+ version: number;
3936
+ /** Base58 peer IDs of the expected cluster nodes. */
3937
+ peer_ids: string[];
3938
+ /** Base64-encoded 48-byte RTMR3 measurements of the expected image(s). */
3939
+ rtmr3_allowlist: string[];
3940
+ /** RFC 3339 timestamp the manifest was signed. */
3941
+ signed_at: string;
3942
+ /** Hex secp256k1 signature (compact 64-byte r‖s) over the canonical payload. */
3943
+ signature: string;
3944
+ }
3945
+ /** The payload fields the signature covers — the manifest minus `signature`. */
3946
+ type TrustManifestPayload = Omit<SignedTrustManifest, "signature">;
3947
+ /**
3948
+ * Verify a manifest's signature against an operator public key (hex
3949
+ * compressed secp256k1). Returns `true` iff the signature is valid for
3950
+ * the manifest's canonical payload. Never throws on a bad signature —
3951
+ * malformed inputs (non-hex key/signature) return `false`.
3952
+ */
3953
+ declare function verifyManifestSignature(manifest: SignedTrustManifest, operatorPublicKeyHex: string): boolean;
3954
+ /** Project a verified manifest onto the `TrustAnchor` the client pins. */
3955
+ declare function manifestToTrustAnchor(manifest: SignedTrustManifest): TrustAnchor;
3956
+ /** Options for {@link fetchTrustedManifest}. */
3957
+ interface FetchTrustedManifestOptions {
3958
+ /**
3959
+ * Override the node base URL the manifest is fetched from (defaults to
3960
+ * the environment's `NODE_URLS` entry). Use for a private-cloud cluster
3961
+ * on a custom host — the manifest is served at `<baseUrl>/api/trust-manifest`.
3962
+ */
3963
+ baseUrl?: string;
3964
+ /**
3965
+ * Override the full manifest URL outright (takes precedence over
3966
+ * `baseUrl`). Primarily for tests and non-standard deployments.
3967
+ */
3968
+ manifestUrl?: string;
3969
+ /**
3970
+ * Override the operator public key (hex compressed secp256k1). Defaults
3971
+ * to the SDK-pinned key for the environment. Primarily for tests.
3972
+ */
3973
+ operatorPublicKeyHex?: string;
3974
+ /**
3975
+ * Reject any manifest whose `version` is below this floor, even when its
3976
+ * signature is valid. Pass this when the application persists the last
3977
+ * accepted version across restarts — it closes the rollback window the
3978
+ * in-process high-water mark cannot cover (a fresh process trusts the
3979
+ * first manifest it sees).
3980
+ */
3981
+ minVersion?: number;
3982
+ }
3983
+ /** Reset the per-environment rollback floor. Useful in tests. */
3984
+ declare function clearManifestVersionFloor(): void;
3985
+ /**
3986
+ * Fetch and verify the operator-signed trust manifest for an environment,
3987
+ * returning a {@link TrustAnchor} ready to pass as
3988
+ * `T3nClientConfig.trustAnchor`.
3989
+ *
3990
+ * Throws if the environment has no pinned operator key (the manifest
3991
+ * infrastructure is not provisioned for it yet), if the manifest cannot
3992
+ * be fetched or is malformed, if the signature does not verify against
3993
+ * the pinned operator key, or if the manifest's `version` is below the
3994
+ * rollback floor (see {@link FetchTrustedManifestOptions.minVersion}).
3995
+ * It never returns an unverified anchor.
3996
+ *
3997
+ * Deliberately uncached (unlike the ML-KEM `keyCache`): the manifest is
3998
+ * re-published on deploys and this function is expected to run once per
3999
+ * application startup, not per handshake. Fetch it once, keep the
4000
+ * returned anchor for the process lifetime, and re-fetch only when a
4001
+ * handshake starts failing verification (a sign the cluster rolled).
4002
+ *
4003
+ * The manifest is served by the node itself at `/api/trust-manifest`
4004
+ * (there is no external bucket) — same origin as the node the anchor
4005
+ * describes. That co-location does not weaken the trust: authenticity is
4006
+ * the operator signature verified against the SDK-pinned key, and the
4007
+ * monotonic version floor rejects replays of an old signed manifest.
4008
+ */
4009
+ declare function fetchTrustedManifest(env: Environment, opts?: FetchTrustedManifestOptions): Promise<TrustAnchor>;
4010
+
3901
4011
  /**
3902
4012
  * Configuration validation for T3n SDK
3903
4013
  */
@@ -4384,5 +4494,5 @@ declare function tenantDidHex(tenantDid: string): string;
4384
4494
  declare function validateTail(tail: string): string;
4385
4495
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
4386
4496
 
4387
- export { AGENT_CARDS_SCOPE, AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, OrgDataClient, OtpRateLimitedError, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, SessionUsageReportClient, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, WireEncodingError, Z_PAYROLL_AUDIT_READ_FUNCTIONS, Z_PAYROLL_RUN_FUNCTIONS, _b64uEncode, assertShape, b64uDecodeStrict, b64uEncodeBytes, bytesToString, canonicalTenantName, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, deriveAgentCardEntryId, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isAgentCardResponse, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isRoleAssignmentsResponse, isRoleGetResponse, isUnsafeTrustServer, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
4388
- export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AssignRolesInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, PurgeOrgInput, QuoteVerifyResult, ReaderSet, RemoveMemberGrantsInput, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetRoleInput, SetWritersInput, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
4497
+ export { AGENT_CARDS_SCOPE, AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, OrgDataClient, OtpRateLimitedError, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, SessionUsageReportClient, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, WireEncodingError, Z_PAYROLL_AUDIT_READ_FUNCTIONS, Z_PAYROLL_RUN_FUNCTIONS, _b64uEncode, assertShape, b64uDecodeStrict, b64uEncodeBytes, bytesToString, canonicalTenantName, clearKeyCache, clearManifestVersionFloor, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, deriveAgentCardEntryId, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, fetchTrustedManifest, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isAgentCardResponse, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isRoleAssignmentsResponse, isRoleGetResponse, isUnsafeTrustServer, loadConfig, loadWasmComponent, manifestToTrustAnchor, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyManifestSignature, verifyTdxQuote };
4498
+ export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AssignRolesInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, FetchTrustedManifestOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, PurgeOrgInput, QuoteVerifyResult, ReaderSet, RemoveMemberGrantsInput, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetRoleInput, SetWritersInput, SignedTrustManifest, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };