@terminal3/t3n-sdk 5.0.0 → 5.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
@@ -1483,6 +1483,12 @@ interface OrgDataActionWire {
1483
1483
  * calling agent to be the `grantee` of at least one grant (subject binding), so
1484
1484
  * an unregistered agent discovers nothing regardless of this list.
1485
1485
  *
1486
+ * Every entry must be a canonical `did:t3n:<40-hex>` identifier. The contract
1487
+ * decodes each one to its 20 bytes, so a value of any other shape refuses the
1488
+ * whole document (the error names the failing index), and two hex casings of one
1489
+ * DID are a duplicate rather than two entries — also a refusal. Use
1490
+ * {@link mergeDiscoverDids} to build the list rather than concatenating.
1491
+ *
1486
1492
  * The document IS the new state on a write: an empty `grants` list revokes all
1487
1493
  * delegated access, and an empty `discover_dids` persists an empty
1488
1494
  * discovery-grant list (there is no per-field merge). Use {@link mergeGrants} /
@@ -1519,8 +1525,20 @@ declare function mergeGrants(existing: BoundGrant[], additions: BoundGrant[]): G
1519
1525
  /**
1520
1526
  * Order-preserving deduplicating union of discovery-grant DID lists — the
1521
1527
  * read-merge-write counterpart of {@link mergeGrants} for the document-level
1522
- * `discover_dids` (the contract rejects duplicate entries, so the union must
1523
- * dedupe).
1528
+ * `discover_dids`.
1529
+ *
1530
+ * A DID's identity is the 20 bytes it decodes to, not its spelling. The contract
1531
+ * dedupes on those bytes and treats a repeat as a hard error over the WHOLE
1532
+ * document, so unioning `did:t3n:AABB…` with `did:t3n:aabb…` has to yield one
1533
+ * entry — matching on the raw string would emit both and lose the write. Each
1534
+ * recognised entry is emitted in canonical lowercase, the form the contract
1535
+ * stores and a later `member-delegation-get` returns, so repeated
1536
+ * read-merge-write cycles converge instead of oscillating.
1537
+ *
1538
+ * An entry that is not a `did:t3n:<40-hex>` identifier at all passes through
1539
+ * verbatim and dedupes by exact string: the contract refuses it and names its
1540
+ * index, which is more use to the caller than this helper dropping it or folding
1541
+ * it into an unrelated entry.
1524
1542
  */
1525
1543
  declare function mergeDiscoverDids(existing: string[], additions: string[]): string[];
1526
1544
  /**
@@ -1617,10 +1635,16 @@ interface AgentAuthEntry {
1617
1635
  * in `agents` (subject binding), so an unregistered agent discovers nothing
1618
1636
  * regardless of this list.
1619
1637
  *
1638
+ * Every entry must be a canonical `did:t3n:<40-hex>` identifier. The legacy
1639
+ * document is converted onto the current one before it is stored, and that
1640
+ * conversion decodes each entry, so anything else refuses the write with the
1641
+ * failing index named.
1642
+ *
1620
1643
  * @deprecated Use {@link MemberDelegationDoc}.
1621
1644
  */
1622
1645
  interface AgentAuthPolicy {
1623
1646
  agents: AgentAuthEntry[];
1647
+ /** Document-level discovery grants (`did:t3n:<40-hex>` entries). */
1624
1648
  discoverDids: string[];
1625
1649
  }
1626
1650
  /**
@@ -1668,6 +1692,10 @@ interface AgentAuthUpdateInput {
1668
1692
  * deny-all egress. The document-level `discover_dids` is emitted only when
1669
1693
  * non-empty; the contract defaults an absent list to empty.
1670
1694
  *
1695
+ * Discovery DIDs are copied through verbatim — no canonicalisation, no dedupe —
1696
+ * so a non-canonical or repeated entry is refused by the contract rather than
1697
+ * quietly repaired here. Build the list with `mergeDiscoverDids`.
1698
+ *
1671
1699
  * @deprecated The new write path passes `MemberDelegationDoc` straight through
1672
1700
  * with no casing transform.
1673
1701
  */
@@ -2398,6 +2426,44 @@ interface GetActivityLogOptions {
2398
2426
  */
2399
2427
  function?: string;
2400
2428
  }
2429
+ /**
2430
+ * Params for a CSV export of the activity log (`exportActivityLog`).
2431
+ *
2432
+ * The read's options minus the paging fields: an export walks the whole window
2433
+ * itself, and the node refuses a request carrying either. Nothing caps the size,
2434
+ * so `{}` on a long-lived organisation is a long walk — send a date range.
2435
+ */
2436
+ type ExportActivityLogOptions = Omit<GetActivityLogOptions, "limit" | "before_seq">;
2437
+ /**
2438
+ * Where an export has got to. Discriminate on `status`; the shape follows it.
2439
+ *
2440
+ * `pending` carries nothing — a half-walked row count is not a fact about the
2441
+ * report. On `failed`, show `reason`: it decides between retrying and narrowing.
2442
+ */
2443
+ type ActivityExportStatus = {
2444
+ status: "pending";
2445
+ } | {
2446
+ status: "ready";
2447
+ rows: number;
2448
+ bytes: number;
2449
+ } | {
2450
+ status: "failed";
2451
+ reason: string;
2452
+ };
2453
+ /** A finished export, as the node hands it back. */
2454
+ interface ActivityExportFile {
2455
+ /** Data rows, excluding the header line. */
2456
+ rows: number;
2457
+ /** Size of {@link csv} in bytes. */
2458
+ bytes: number;
2459
+ /**
2460
+ * The CSV text, header row first. Columns are fixed: `seq_no`, `timestamp_ms`,
2461
+ * `caller_type`, `actor`, `on_behalf_of`, `org`, `contract`, `function`,
2462
+ * `outcome`. For a browser download, wrap it in a `Blob` and click
2463
+ * an `<a download>` — the response is sealed, so there is no URL to navigate.
2464
+ */
2465
+ csv: string;
2466
+ }
2401
2467
 
2402
2468
  /**
2403
2469
  * Contract-discovery wire shapes.
@@ -2901,6 +2967,38 @@ declare class T3nClient {
2901
2967
  * ```
2902
2968
  */
2903
2969
  getActivityLog(opts?: GetActivityLogOptions): Promise<ActivityReport>;
2970
+ /**
2971
+ * Start a CSV export of the caller's organisation's activity log, returning
2972
+ * its id. Scope and filters are {@link getActivityLog}'s — the export is that
2973
+ * read walked to exhaustion. Poll {@link getActivityLogExportStatus}, then
2974
+ * {@link downloadActivityLogExport}, or let {@link exportActivityLog} do all
2975
+ * three. A caller who already has one running gets `-32002`.
2976
+ */
2977
+ startActivityLogExport(opts?: ExportActivityLogOptions): Promise<string>;
2978
+ /**
2979
+ * Where one of the caller's own exports has got to. Anyone else's id reads as
2980
+ * absent — an export id is not a capability.
2981
+ */
2982
+ getActivityLogExportStatus(exportId: string): Promise<ActivityExportStatus>;
2983
+ /**
2984
+ * Fetch a finished export — the whole file in one sealed response, so hold the
2985
+ * result rather than re-fetching per render. Fetchable until your next export
2986
+ * replaces it, so a dead transfer retries on the same id; called while the walk
2987
+ * still runs, it throws instead of waiting.
2988
+ */
2989
+ downloadActivityLogExport(exportId: string): Promise<ActivityExportFile>;
2990
+ /**
2991
+ * Export the activity log to CSV: start, poll, return the file. Use the three
2992
+ * calls above instead when the UI must own the polling (to survive a page
2993
+ * reload). Rejects with the node's reason if the export gives up, and on
2994
+ * `timeoutMs` — after which the job keeps running, so the id stays pollable.
2995
+ */
2996
+ exportActivityLog(opts?: ExportActivityLogOptions, poll?: {
2997
+ /** Gap between status polls. Default 1s. */
2998
+ pollIntervalMs?: number;
2999
+ /** Give up waiting after this. Default 5 minutes. */
3000
+ timeoutMs?: number;
3001
+ }): Promise<ActivityExportFile>;
2904
3002
  /**
2905
3003
  * Execute an action with an attached binary blob using multipart RPC.
2906
3004
  */
@@ -5960,4 +6058,4 @@ declare function validateTail(tail: string): string;
5960
6058
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
5961
6059
 
5962
6060
  export { AGENT_CARDS_SCOPE, AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, InvokeError, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, OrgDataClient, OtpRateLimitedError, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, SessionUsageReportClient, T3nClient, T3nConfigError, 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, buildSecretWriteArgs, bytesToString, canonicalTenantName, clearKeyCache, clearManifestVersionFloor, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, deriveAgentCardEntryId, discoverCheckDelegation, discoverDescribeContract, discoverDescribeFunction, discoverListContracts, discoverWhoami, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, fetchTrustedManifest, formatTokens, generateRandomString, generateUUID, getContractVersion, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, invoke, isAgentCardResponse, isAgentEgressGetResponse, isDataGetResponse, isDataListResponse, isListAgentsResponse, isListHumanMembersResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractDelegation, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isRoleAssignmentsResponse, isRoleGetResponse, isSecretListResponse, isSecretRecord, isSecretView, isUnsafeTrustServer, loadConfig, loadWasmComponent, manifestToTrustAnchor, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, mergeGrants, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, parseMemberDelegationDoc, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyManifestSignature, verifyTdxQuote };
5963
- export type { ActivityCallerType, ActivityEntry, ActivityOutcome, ActivityReport, AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentEgressEntry, AgentEgressGetResponse, AgentEgressRefInput, AgentSummary, AssignRolesInput, AuthInput, BalanceRow, BoundGrant, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractDescriptorDocument, ContractDescriptorFacets, ContractExecuteInput, ContractKind, ContractLifecycleStatus, ContractListDetailedOptions, ContractListDetailedPage, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, DescribeContractParams, DescribeContractResult, DescribeFunctionParams, DescribeFunctionResult, DetailedContract, Did, Direction, DiscoverOptions, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, FetchTrustedManifestOptions, FunctionDescriptorEntry, GetActivityLogOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GrantsMergeResult, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, HumanMember, InvokeOptions, InvokeRequest, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListAgentsInput, ListAgentsResponse, ListContractsParams, ListContractsResult, ListContractsScope, ListHumanMembersInput, ListHumanMembersResponse, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MemberDelegationDoc, MemberRole, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractDelegation, OrgContractGrants, 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, RemoveMemberGrantsInput, RemoveTarget, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SecretKind, SecretListInput, SecretListResponse, SecretNameInput, SecretRecord, SecretSetValueInput, SecretView, SecretWriteInput, SessionCrypto, SessionId, SetAgentEgressInput, 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, TrustAnchorSource, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, Validity, WasmComponent, WasmNextResult, WhoamiResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
6061
+ export type { ActivityCallerType, ActivityEntry, ActivityExportFile, ActivityExportStatus, ActivityOutcome, ActivityReport, AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentEgressEntry, AgentEgressGetResponse, AgentEgressRefInput, AgentSummary, AssignRolesInput, AuthInput, BalanceRow, BoundGrant, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractDescriptorDocument, ContractDescriptorFacets, ContractExecuteInput, ContractKind, ContractLifecycleStatus, ContractListDetailedOptions, ContractListDetailedPage, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, DescribeContractParams, DescribeContractResult, DescribeFunctionParams, DescribeFunctionResult, DetailedContract, Did, Direction, DiscoverOptions, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, ExportActivityLogOptions, FetchTrustedManifestOptions, FunctionDescriptorEntry, GetActivityLogOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GrantsMergeResult, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, HumanMember, InvokeOptions, InvokeRequest, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListAgentsInput, ListAgentsResponse, ListContractsParams, ListContractsResult, ListContractsScope, ListHumanMembersInput, ListHumanMembersResponse, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MemberDelegationDoc, MemberRole, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractDelegation, OrgContractGrants, 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, RemoveMemberGrantsInput, RemoveTarget, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SecretKind, SecretListInput, SecretListResponse, SecretNameInput, SecretRecord, SecretSetValueInput, SecretView, SecretWriteInput, SessionCrypto, SessionId, SetAgentEgressInput, 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, TrustAnchorSource, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, Validity, WasmComponent, WasmNextResult, WhoamiResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };