@terminal3/t3n-sdk 4.0.4 → 4.2.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
@@ -282,7 +282,8 @@ declare enum SessionStatus {
282
282
  declare enum AuthMethod {
283
283
  Ethereum = "eth",
284
284
  OIDC = "oidc",
285
- EmailOtp = "email_otp"
285
+ EmailOtp = "email_otp",
286
+ Workload = "workload"
286
287
  }
287
288
  /**
288
289
  * OIDC credentials interface.
@@ -344,16 +345,42 @@ interface EmailOtpAuthInput extends BaseAuthInput {
344
345
  method: AuthMethod.EmailOtp;
345
346
  credentials: EmailOtpCredentials;
346
347
  }
348
+ /**
349
+ * Workload authentication input (keyless hosted-agent auth).
350
+ *
351
+ * Unlike {@link OidcAuthInput}, this is a SINGLE-call flow: there is no
352
+ * session-binding nonce and no `InitOidcAuth` round-trip. The caller
353
+ * supplies a pre-fetched OIDC **workload** `idToken` (the agent's own
354
+ * machine identity — its `(iss, sub)`) directly by value, and the node
355
+ * verifies it and mints/resolves the DID `oidc:<iss>:<sub>` server-side
356
+ * via a single `SubmitWorkloadToken` action.
357
+ *
358
+ * The token is carried by value (not behind a `getIdToken(nonce)`
359
+ * callback like {@link OidcCredentials}) because callers re-source a
360
+ * fresh token per session open — `id_token`s expire, so nothing here
361
+ * should be cached across sessions.
362
+ */
363
+ interface WorkloadAuthInput extends BaseAuthInput {
364
+ method: AuthMethod.Workload;
365
+ provider: string;
366
+ idToken: string;
367
+ }
347
368
  /**
348
369
  * Union type for all supported authentication inputs
349
370
  */
350
- type AuthInput = EthAuthInput | OidcAuthInput | EmailOtpAuthInput;
371
+ type AuthInput = EthAuthInput | OidcAuthInput | EmailOtpAuthInput | WorkloadAuthInput;
351
372
  /**
352
373
  * Helper functions to create auth inputs
353
374
  */
354
375
  declare function createEthAuthInput(address: string, options?: EthAuthOptions): EthAuthInput;
355
376
  declare function createOidcAuthInput(credentials: OidcCredentials): OidcAuthInput;
356
377
  declare function createEmailOtpAuthInput(credentials: EmailOtpCredentials): EmailOtpAuthInput;
378
+ /**
379
+ * Build a keyless workload auth input from a pre-fetched OIDC workload
380
+ * `id_token`. Single-call (no nonce round-trip); the token must be the
381
+ * agent's OWN machine identity — see {@link WorkloadAuthInput}.
382
+ */
383
+ declare function createWorkloadAuthInput(provider: string, idToken: string): WorkloadAuthInput;
357
384
 
358
385
  /**
359
386
  * Error classes for T3n SDK
@@ -1713,6 +1740,35 @@ declare class T3nClient {
1713
1740
  * returns `Finish { did }`.
1714
1741
  */
1715
1742
  private authenticateOidc;
1743
+ /**
1744
+ * Parse a `Finish { did }` reply shared by the manual (non-WASM) auth flows
1745
+ * that bypass the client state machine (interactive OIDC, keyless workload).
1746
+ *
1747
+ * Validates the `oidc_auth_action` tag before reading `did`: a decodable but
1748
+ * non-`Finish` reply is reported as such rather than silently misread as a
1749
+ * missing DID (which would discard whatever the server actually said). Returns
1750
+ * the session {@link Did}.
1751
+ */
1752
+ private parseFinishDid;
1753
+ /**
1754
+ * Workload (keyless hosted-agent) single-call authentication.
1755
+ *
1756
+ * A hosted agent authenticates with its OWN OIDC workload identity —
1757
+ * a machine `id_token` whose `(iss, sub)` the caller has already
1758
+ * fetched — forwarded through this transport by value. Distinct from
1759
+ * the interactive {@link authenticateOidc} flow: there is NO
1760
+ * session-binding nonce and NO `InitOidcAuth` round-trip. We make a
1761
+ * SINGLE encrypted RPC call:
1762
+ *
1763
+ * 1. `SubmitWorkloadToken { provider, id_token }` → the node verifies
1764
+ * the token and mints/resolves the DID `oidc:<iss>:<sub>` →
1765
+ * returns `Finish { did }`.
1766
+ *
1767
+ * Bypasses the WASM client state machine (mirrors `authenticateOidc` /
1768
+ * `authenticateEmailOtp`); the `SubmitWorkloadToken` action tag is
1769
+ * matched server-side.
1770
+ */
1771
+ private authenticateWorkload;
1716
1772
  /**
1717
1773
  * Email-OTP two-step authentication.
1718
1774
  *
@@ -3403,5 +3459,5 @@ declare function tenantDidHex(tenantDid: string): string;
3403
3459
  declare function validateTail(tail: string): string;
3404
3460
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
3405
3461
 
3406
- export { 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, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, 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, decodeWasmErrorMessage, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgWriters, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, metamask_get_address, metamask_sign, parseAgentAuthGet, parseContractResponse, redactSecrets, redactSecretsFromJson, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
3407
- export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthScriptGrant, AgentAuthUpdateInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, Logger, MapCreateInput, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ReaderSet, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, UpdateMetaInput, UsageEntry, UsagePage, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WriteDataInput, WriterSet, WritersGetInput };
3462
+ export { 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, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, 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, createWorkloadAuthInput, decodeWasmErrorMessage, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgWriters, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, metamask_get_address, metamask_sign, parseAgentAuthGet, parseContractResponse, redactSecrets, redactSecretsFromJson, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
3463
+ export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthScriptGrant, AgentAuthUpdateInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, Logger, MapCreateInput, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ReaderSet, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, UpdateMetaInput, UsageEntry, UsagePage, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };