@terminal3/t3n-sdk 2.12.0 → 3.0.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
@@ -554,6 +554,8 @@ interface UserInputProfile {
554
554
  phone_number?: string;
555
555
  birthdate?: string;
556
556
  nationality?: string;
557
+ campaign_code?: string;
558
+ role?: string;
557
559
  [key: string]: unknown;
558
560
  }
559
561
  /**
@@ -1966,6 +1968,13 @@ declare const NONCE_LEN = 16;
1966
1968
  declare const REQUEST_HASH_LEN = 32;
1967
1969
  declare const AGENT_PUBKEY_LEN = 33;
1968
1970
  declare const ETH_SIG_LEN = 65;
1971
+ declare const MAX_FUNCTIONS_PER_CREDENTIAL = 16;
1972
+ /**
1973
+ * Canonical sorted list of the payroll v2 function surface. One source
1974
+ * of truth for callers building a full-cycle credential — pass this
1975
+ * (or a sorted subset) as `functions` to {@link buildDelegationCredential}.
1976
+ */
1977
+ declare const PAYROLL_FUNCTIONS_V1: readonly ["compute-payroll", "execute-disbursement", "finalize-audit", "submit-escalations", "validate-credentials"];
1969
1978
  /** User-to-agent delegation credential body. */
1970
1979
  interface DelegationCredential {
1971
1980
  /** Domain tag, must equal {@link DELEGATION_CREDENTIAL_DOMAIN}. */
@@ -1978,8 +1987,11 @@ interface DelegationCredential {
1978
1987
  org_did: string;
1979
1988
  /** Contract id, e.g. `"tee:payroll"`. */
1980
1989
  contract: string;
1981
- /** Function name, e.g. `"run-payroll"`. */
1982
- function: string;
1990
+ /**
1991
+ * Functions this credential authorises. Sorted ascending, deduped,
1992
+ * each entry non-empty lowercase ASCII, 1..=16 entries.
1993
+ */
1994
+ functions: string[];
1983
1995
  /** Org-data scopes the contract may read on this user's behalf. */
1984
1996
  scopes: string[];
1985
1997
  /** Flat key-value labels checked against the org grant. */
@@ -2102,7 +2114,12 @@ interface BuildDelegationCredentialOpts {
2102
2114
  agent_pubkey: Uint8Array;
2103
2115
  org_did: string;
2104
2116
  contract: string;
2105
- function: string;
2117
+ /**
2118
+ * Functions this credential authorises. Must be non-empty, sorted
2119
+ * ascending, deduped — the same invariants enforced by
2120
+ * {@link validateCredentialBody}.
2121
+ */
2122
+ functions: string[];
2106
2123
  scopes?: string[];
2107
2124
  metadata?: Record<string, string>;
2108
2125
  not_before_secs: bigint | number;
@@ -2208,6 +2225,54 @@ declare class DelegationCustodialClient {
2208
2225
  */
2209
2226
  signCustodial(body: Record<string, unknown>): Promise<SignCustodialResult>;
2210
2227
  }
2228
+ /** Options for {@link revokeDelegation}. */
2229
+ interface RevokeDelegationOpts {
2230
+ /** Credential body to revoke. Already-encoded base64url-no-pad JCS bytes. */
2231
+ credentialJcsB64u: string;
2232
+ /**
2233
+ * Omit (or pass `undefined`) to revoke the whole credential. Pass an
2234
+ * array of function names to revoke a subset; the array must obey the
2235
+ * same sort + dedupe invariants the credential's `functions` field
2236
+ * enforces, and each entry must already appear in the credential's
2237
+ * `functions` list (a revocation can only narrow the set, never grow
2238
+ * it).
2239
+ */
2240
+ revokedFunctions?: string[];
2241
+ /** Authenticated {@link T3nClient} for the credential's `user_did`. */
2242
+ client: T3nClient;
2243
+ /**
2244
+ * Override the resolved delegation contract version. Defaults to
2245
+ * whatever `GET /api/contracts/current?name=tee:delegation/contracts`
2246
+ * returns at call time.
2247
+ */
2248
+ scriptVersion?: string;
2249
+ /** Override the node base URL used for `"latest"` resolution. */
2250
+ baseUrl?: string;
2251
+ }
2252
+ /** Result of a successful {@link revokeDelegation} call. */
2253
+ interface RevokeDelegationResult {
2254
+ /** Credential id (base64url-no-pad, no padding). */
2255
+ vcId: string;
2256
+ /**
2257
+ * Mirrors the persisted revocation state after merging: `null` means
2258
+ * whole-credential, a sorted array means per-function. The contract
2259
+ * may return a larger set than `opts.revokedFunctions` when an
2260
+ * earlier per-function revocation existed for the same credential.
2261
+ */
2262
+ revokedFunctions: string[] | null;
2263
+ }
2264
+ /**
2265
+ * Wraps the `tee:delegation/contracts::revoke` entrypoint. Only the
2266
+ * credential's `user_did` may call this — the contract reads the
2267
+ * authenticated DID from session context and rejects any other caller
2268
+ * with `NotCredentialHolder`.
2269
+ *
2270
+ * Merge semantics are handled server-side: whole-credential revocations
2271
+ * are sticky, and per-function revocations accumulate as a sorted +
2272
+ * deduped union across calls. The returned `revokedFunctions` reflects
2273
+ * the persisted state after merging, not just this call's input.
2274
+ */
2275
+ declare function revokeDelegation(opts: RevokeDelegationOpts): Promise<RevokeDelegationResult>;
2211
2276
  /** Options for {@link buildPayrollInvocation}. */
2212
2277
  interface BuildPayrollInvocationOpts {
2213
2278
  credentialJcs: Uint8Array;
@@ -2767,5 +2832,5 @@ declare function clearKeyCache(): void;
2767
2832
  */
2768
2833
  declare function loadConfig(baseUrl?: string): SdkConfig;
2769
2834
 
2770
- 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 };
2771
- 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, TenantAdmitProjection, TenantAdmitStatus, Transport, UpdateMetaInput, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WriteDataInput, WritersGetInput };
2835
+ 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, MAX_FUNCTIONS_PER_CREDENTIAL, MockTransport, NODE_URLS, NONCE_LEN, OrgDataClient, PAYROLL_FUNCTIONS_V1, 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, revokeDelegation, setEnvironment, setGlobalLogLevel, setNodeUrl, signAgentInvocation, signCredential, stringToBytes, validateConfig, validateCredentialBody, verifyDkgAttestation, verifyTdxQuote };
2836
+ 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, RevokeDelegationOpts, RevokeDelegationResult, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, SignCustodialResult, SignDelegationResponse, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, Transport, UpdateMetaInput, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WriteDataInput, WritersGetInput };