@terminal3/t3n-sdk 2.13.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 +68 -5
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/delegation.d.ts +66 -3
- package/dist/src/index.d.ts +2 -2
- package/package.json +1 -3
|
@@ -31,11 +31,18 @@ export declare const AGENT_PUBKEY_LEN = 33;
|
|
|
31
31
|
export declare const ETH_SIG_LEN = 65;
|
|
32
32
|
export declare const MAX_CONTRACT_LEN = 46;
|
|
33
33
|
export declare const MAX_FUNCTION_LEN = 64;
|
|
34
|
+
export declare const MAX_FUNCTIONS_PER_CREDENTIAL = 16;
|
|
34
35
|
export declare const MAX_SCOPE_LEN = 64;
|
|
35
36
|
export declare const MAX_SCOPES_PER_CREDENTIAL = 32;
|
|
36
37
|
export declare const MAX_METADATA_PER_CREDENTIAL = 16;
|
|
37
38
|
export declare const MAX_METADATA_KEY_LEN = 64;
|
|
38
39
|
export declare const MAX_METADATA_VALUE_LEN = 256;
|
|
40
|
+
/**
|
|
41
|
+
* Canonical sorted list of the payroll v2 function surface. One source
|
|
42
|
+
* of truth for callers building a full-cycle credential — pass this
|
|
43
|
+
* (or a sorted subset) as `functions` to {@link buildDelegationCredential}.
|
|
44
|
+
*/
|
|
45
|
+
export declare const PAYROLL_FUNCTIONS_V1: readonly ["compute-payroll", "execute-disbursement", "finalize-audit", "submit-escalations", "validate-credentials"];
|
|
39
46
|
/** User-to-agent delegation credential body. */
|
|
40
47
|
export interface DelegationCredential {
|
|
41
48
|
/** Domain tag, must equal {@link DELEGATION_CREDENTIAL_DOMAIN}. */
|
|
@@ -48,8 +55,11 @@ export interface DelegationCredential {
|
|
|
48
55
|
org_did: string;
|
|
49
56
|
/** Contract id, e.g. `"tee:payroll"`. */
|
|
50
57
|
contract: string;
|
|
51
|
-
/**
|
|
52
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Functions this credential authorises. Sorted ascending, deduped,
|
|
60
|
+
* each entry non-empty lowercase ASCII, 1..=16 entries.
|
|
61
|
+
*/
|
|
62
|
+
functions: string[];
|
|
53
63
|
/** Org-data scopes the contract may read on this user's behalf. */
|
|
54
64
|
scopes: string[];
|
|
55
65
|
/** Flat key-value labels checked against the org grant. */
|
|
@@ -176,7 +186,12 @@ export interface BuildDelegationCredentialOpts {
|
|
|
176
186
|
agent_pubkey: Uint8Array;
|
|
177
187
|
org_did: string;
|
|
178
188
|
contract: string;
|
|
179
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Functions this credential authorises. Must be non-empty, sorted
|
|
191
|
+
* ascending, deduped — the same invariants enforced by
|
|
192
|
+
* {@link validateCredentialBody}.
|
|
193
|
+
*/
|
|
194
|
+
functions: string[];
|
|
180
195
|
scopes?: string[];
|
|
181
196
|
metadata?: Record<string, string>;
|
|
182
197
|
not_before_secs: bigint | number;
|
|
@@ -282,6 +297,54 @@ export declare class DelegationCustodialClient {
|
|
|
282
297
|
*/
|
|
283
298
|
signCustodial(body: Record<string, unknown>): Promise<SignCustodialResult>;
|
|
284
299
|
}
|
|
300
|
+
/** Options for {@link revokeDelegation}. */
|
|
301
|
+
export interface RevokeDelegationOpts {
|
|
302
|
+
/** Credential body to revoke. Already-encoded base64url-no-pad JCS bytes. */
|
|
303
|
+
credentialJcsB64u: string;
|
|
304
|
+
/**
|
|
305
|
+
* Omit (or pass `undefined`) to revoke the whole credential. Pass an
|
|
306
|
+
* array of function names to revoke a subset; the array must obey the
|
|
307
|
+
* same sort + dedupe invariants the credential's `functions` field
|
|
308
|
+
* enforces, and each entry must already appear in the credential's
|
|
309
|
+
* `functions` list (a revocation can only narrow the set, never grow
|
|
310
|
+
* it).
|
|
311
|
+
*/
|
|
312
|
+
revokedFunctions?: string[];
|
|
313
|
+
/** Authenticated {@link T3nClient} for the credential's `user_did`. */
|
|
314
|
+
client: import("./t3n-client").T3nClient;
|
|
315
|
+
/**
|
|
316
|
+
* Override the resolved delegation contract version. Defaults to
|
|
317
|
+
* whatever `GET /api/contracts/current?name=tee:delegation/contracts`
|
|
318
|
+
* returns at call time.
|
|
319
|
+
*/
|
|
320
|
+
scriptVersion?: string;
|
|
321
|
+
/** Override the node base URL used for `"latest"` resolution. */
|
|
322
|
+
baseUrl?: string;
|
|
323
|
+
}
|
|
324
|
+
/** Result of a successful {@link revokeDelegation} call. */
|
|
325
|
+
export interface RevokeDelegationResult {
|
|
326
|
+
/** Credential id (base64url-no-pad, no padding). */
|
|
327
|
+
vcId: string;
|
|
328
|
+
/**
|
|
329
|
+
* Mirrors the persisted revocation state after merging: `null` means
|
|
330
|
+
* whole-credential, a sorted array means per-function. The contract
|
|
331
|
+
* may return a larger set than `opts.revokedFunctions` when an
|
|
332
|
+
* earlier per-function revocation existed for the same credential.
|
|
333
|
+
*/
|
|
334
|
+
revokedFunctions: string[] | null;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Wraps the `tee:delegation/contracts::revoke` entrypoint. Only the
|
|
338
|
+
* credential's `user_did` may call this — the contract reads the
|
|
339
|
+
* authenticated DID from session context and rejects any other caller
|
|
340
|
+
* with `NotCredentialHolder`.
|
|
341
|
+
*
|
|
342
|
+
* Merge semantics are handled server-side: whole-credential revocations
|
|
343
|
+
* are sticky, and per-function revocations accumulate as a sorted +
|
|
344
|
+
* deduped union across calls. The returned `revokedFunctions` reflects
|
|
345
|
+
* the persisted state after merging, not just this call's input.
|
|
346
|
+
*/
|
|
347
|
+
export declare function revokeDelegation(opts: RevokeDelegationOpts): Promise<RevokeDelegationResult>;
|
|
285
348
|
/** Options for {@link buildPayrollInvocation}. */
|
|
286
349
|
export interface BuildPayrollInvocationOpts {
|
|
287
350
|
credentialJcs: Uint8Array;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export type { OrgDataClientOptions, CreatePolicyInput, UpdateMetaInput, SetWrite
|
|
|
25
25
|
export type { OrgDataActionWire, OrgPolicyMeta, OrgWriters, OrgContractGrants, UserGrant, EmployeeRecord, EmploymentStatus, ResidencyCategory, AgeBand, ExpenseClaim, MutationResponse, DataListResponse, DataGetResponse, } from "./types/org-data";
|
|
26
26
|
export { DelegationCustodialClient } from "./client/delegation";
|
|
27
27
|
export type { DelegationCustodialClientOpts, SignCustodialResult, } from "./client/delegation";
|
|
28
|
-
export { DELEGATION_CREDENTIAL_DOMAIN, DELEGATION_INVOCATION_DOMAIN, VC_ID_LEN, NONCE_LEN, REQUEST_HASH_LEN, AGENT_PUBKEY_LEN, ETH_SIG_LEN, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, buildDelegationCredential, validateCredentialBody, canonicaliseCredential, canonicaliseRequest, requestHash, buildInvocationPreimage, eip191Digest, signCredential, ethRecoverEip191, signAgentInvocation, buildPayrollInvocation, buildPayrollDirectInvocation, compactDidFromBytes, b64uEncodeBytes, b64uDecodeStrict, _b64uEncode, } from "./client/delegation";
|
|
29
|
-
export type { DelegationCredential, DelegationEnvelope, PayrollRunRequest, PayrollInvocationDelegated, PayrollInvocationDirect, PayrollInvocation, SignDelegationResponse, BuildDelegationCredentialOpts, BuildPayrollInvocationOpts, BuildPayrollDirectInvocationOpts, } from "./client/delegation";
|
|
28
|
+
export { DELEGATION_CREDENTIAL_DOMAIN, DELEGATION_INVOCATION_DOMAIN, VC_ID_LEN, NONCE_LEN, REQUEST_HASH_LEN, AGENT_PUBKEY_LEN, ETH_SIG_LEN, MAX_FUNCTIONS_PER_CREDENTIAL, PAYROLL_FUNCTIONS_V1, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, buildDelegationCredential, validateCredentialBody, canonicaliseCredential, canonicaliseRequest, requestHash, buildInvocationPreimage, eip191Digest, signCredential, ethRecoverEip191, signAgentInvocation, buildPayrollInvocation, buildPayrollDirectInvocation, revokeDelegation, compactDidFromBytes, b64uEncodeBytes, b64uDecodeStrict, _b64uEncode, } from "./client/delegation";
|
|
29
|
+
export type { DelegationCredential, DelegationEnvelope, PayrollRunRequest, PayrollInvocationDelegated, PayrollInvocationDirect, PayrollInvocation, SignDelegationResponse, BuildDelegationCredentialOpts, BuildPayrollInvocationOpts, BuildPayrollDirectInvocationOpts, RevokeDelegationOpts, RevokeDelegationResult, } from "./client/delegation";
|
|
30
30
|
export { metamask_sign, metamask_get_address, eth_get_address, createDefaultHandlers, createMlKemPublicKeyHandler, createRandomHandler, } from "./client/handlers";
|
|
31
31
|
export type { WasmComponent, ClientHandshake, ClientAuth, SessionCrypto, WasmNextResult, } from "./wasm";
|
|
32
32
|
export { loadWasmComponent } from "./wasm";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terminal3/t3n-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "T3n TypeScript SDK - A minimal SDK that mirrors the server's RPC handler approach",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,8 +30,6 @@
|
|
|
30
30
|
"copy-wasm": "mkdir -p dist/wasm/generated && cp -r src/wasm/generated/* dist/wasm/generated/",
|
|
31
31
|
"test": "vitest run",
|
|
32
32
|
"test:watch": "vitest",
|
|
33
|
-
"e2e:agent": "tsx scripts/payroll-v2-agent-e2e.ts",
|
|
34
|
-
"e2e:member": "tsx scripts/payroll-v2-e2e.ts",
|
|
35
33
|
"store-token": "tsx scripts/payroll-v2-store-token.ts",
|
|
36
34
|
"test:coverage": "vitest run --coverage",
|
|
37
35
|
"lint": "eslint src --ext .ts,.tsx",
|