@terminal3/t3n-sdk 2.4.0 → 2.5.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 +391 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/client/delegation.d.ts +57 -0
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/org-data.d.ts +201 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/org-data.d.ts +147 -0
- package/package.json +4 -1
|
@@ -196,6 +196,63 @@ export declare function ethRecoverEip191(msg: Uint8Array, sig: Uint8Array): Uint
|
|
|
196
196
|
* `delegation-types::verify_agent_sig` accepts as the 64-byte form.
|
|
197
197
|
*/
|
|
198
198
|
export declare function signAgentInvocation(preimage: Uint8Array, secret: Uint8Array): Uint8Array;
|
|
199
|
+
/**
|
|
200
|
+
* Options for {@link DelegationCustodialClient}.
|
|
201
|
+
*/
|
|
202
|
+
export interface DelegationCustodialClientOpts {
|
|
203
|
+
/**
|
|
204
|
+
* Explicit semver string for the delegation contract (e.g. `"1.0.0"`).
|
|
205
|
+
* When omitted the client resolves `"latest"` via
|
|
206
|
+
* `GET /api/contracts/current?name=tee:delegation/contracts` (one
|
|
207
|
+
* request per client instance, cached in `getScriptVersion`).
|
|
208
|
+
*/
|
|
209
|
+
scriptVersion?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Result returned by {@link DelegationCustodialClient.signCustodial}.
|
|
213
|
+
*/
|
|
214
|
+
export interface SignCustodialResult {
|
|
215
|
+
/** RFC 8785 JCS bytes of the credential, exactly as signed by the node. */
|
|
216
|
+
credentialJcs: Uint8Array;
|
|
217
|
+
/** 65-byte EIP-191 signature over `credentialJcs` produced by the TEE. */
|
|
218
|
+
userSig: Uint8Array;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Wraps the `tee:delegation/contracts::sign` function for OIDC users
|
|
222
|
+
* (or any user whose private key is held by the TEE rather than the
|
|
223
|
+
* browser).
|
|
224
|
+
*
|
|
225
|
+
* ETH-EOA users who hold their own key should call
|
|
226
|
+
* {@link signCredential} directly — no network round-trip required.
|
|
227
|
+
*
|
|
228
|
+
* The client must be constructed with an authenticated {@link T3nClient}
|
|
229
|
+
* instance and the node's base URL; `signCustodial` sends the credential
|
|
230
|
+
* body to the TEE and returns the signed bytes.
|
|
231
|
+
*
|
|
232
|
+
* Reference: `node/tests/harness/src/payroll_seed.rs` (the
|
|
233
|
+
* `tee:delegation.sign` invocation at line 550).
|
|
234
|
+
*/
|
|
235
|
+
export declare class DelegationCustodialClient {
|
|
236
|
+
private readonly t3n;
|
|
237
|
+
private readonly baseUrl;
|
|
238
|
+
private readonly opts;
|
|
239
|
+
constructor(t3n: import("./t3n-client").T3nClient, baseUrl: string, opts?: DelegationCustodialClientOpts);
|
|
240
|
+
/**
|
|
241
|
+
* Request the TEE to sign a delegation credential on behalf of the
|
|
242
|
+
* authenticated user.
|
|
243
|
+
*
|
|
244
|
+
* The `body` is sent as-is as the `input.body` field of the
|
|
245
|
+
* `tee:delegation/contracts::sign` action. Use
|
|
246
|
+
* {@link buildDelegationCredential} + the wire-shape projection to
|
|
247
|
+
* produce the correct representation — binary fields (`agent_pubkey`,
|
|
248
|
+
* `vc_id`) must be base64url-no-pad strings, and `not_before_secs` /
|
|
249
|
+
* `not_after_secs` must be decimal strings.
|
|
250
|
+
*
|
|
251
|
+
* Returns `{ credentialJcs, userSig }` — both as `Uint8Array` — ready
|
|
252
|
+
* to be passed into {@link buildPayrollInvocation}.
|
|
253
|
+
*/
|
|
254
|
+
signCustodial(body: Record<string, unknown>): Promise<SignCustodialResult>;
|
|
255
|
+
}
|
|
199
256
|
/** Options for {@link buildPayrollInvocation}. */
|
|
200
257
|
export interface BuildPayrollInvocationOpts {
|
|
201
258
|
credentialJcs: Uint8Array;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OrgDataClient — user-signed org-data dispatch client.
|
|
3
|
+
*
|
|
4
|
+
* Implements the two-step flow that `node/service/src/org_data.rs`
|
|
5
|
+
* defines:
|
|
6
|
+
*
|
|
7
|
+
* 1. `POST /api/org-data/nonce` — fetch a single-use replay nonce.
|
|
8
|
+
* 2. `POST /api/org-data/execute` — submit a signed envelope whose
|
|
9
|
+
* EIP-191 signature covers the canonical JSON of the eight
|
|
10
|
+
* `SignableEnvelope` fields, in the exact field-declaration order
|
|
11
|
+
* used by the Rust struct (see `org_data.rs` lines 104–117).
|
|
12
|
+
*
|
|
13
|
+
* The `args_hash` is `hex(sha256(JSON.stringify(args)))` — the same
|
|
14
|
+
* binding the Rust harness (`org_data_client.rs`) computes.
|
|
15
|
+
*
|
|
16
|
+
* `authenticator_id` is `"eth:0x<40 lowercase hex>"` derived
|
|
17
|
+
* deterministically from the caller's ETH secret key.
|
|
18
|
+
*/
|
|
19
|
+
import type { OrgContractGrants, OrgPolicyMeta, OrgWriters, DataListResponse, DataGetResponse, MutationResponse, UserGrant } from "../types/org-data";
|
|
20
|
+
/**
|
|
21
|
+
* Derive the `"eth:0x<40 lowercase hex>"` authenticator string
|
|
22
|
+
* deterministically from a 32-byte ETH secret key.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors `authenticator_id_from_eth_secret` in
|
|
25
|
+
* `node/tests/harness/src/org_data_client.rs`.
|
|
26
|
+
*/
|
|
27
|
+
declare function authenticatorIdFromEthSecret(ethSecret: Uint8Array): string;
|
|
28
|
+
/**
|
|
29
|
+
* Options accepted by {@link executeOrgDataAction}.
|
|
30
|
+
*/
|
|
31
|
+
export interface ExecuteOrgDataActionOptions {
|
|
32
|
+
/** Envelope TTL in seconds. Defaults to {@link DEFAULT_ENVELOPE_TTL_SECS}. */
|
|
33
|
+
ttlSecs?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sign and dispatch a user-authenticated org-data action.
|
|
37
|
+
*
|
|
38
|
+
* `args` MUST contain an `org_did` field matching `orgDid` — the
|
|
39
|
+
* service verifies envelope-vs-args binding before dispatching.
|
|
40
|
+
*
|
|
41
|
+
* Returns the contract's JSON response on success.
|
|
42
|
+
*/
|
|
43
|
+
declare function executeOrgDataAction(baseUrl: string, ethSecret: Uint8Array, userDid: string, orgDid: string, functionName: string, args: Record<string, unknown>, opts?: ExecuteOrgDataActionOptions): Promise<unknown>;
|
|
44
|
+
export interface CreatePolicyInput {
|
|
45
|
+
orgDid: string;
|
|
46
|
+
initialAdminDid: string;
|
|
47
|
+
maxAdmins?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface UpdateMetaInput {
|
|
50
|
+
orgDid: string;
|
|
51
|
+
admins: string[];
|
|
52
|
+
maxAdmins?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface SetWritersInput {
|
|
55
|
+
orgDid: string;
|
|
56
|
+
scope: string;
|
|
57
|
+
writers: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface SetGrantsInput {
|
|
60
|
+
orgDid: string;
|
|
61
|
+
contractId: string;
|
|
62
|
+
grants: UserGrant[];
|
|
63
|
+
}
|
|
64
|
+
export interface DeleteGrantsInput {
|
|
65
|
+
orgDid: string;
|
|
66
|
+
contractId: string;
|
|
67
|
+
}
|
|
68
|
+
export interface WriteDataInput {
|
|
69
|
+
orgDid: string;
|
|
70
|
+
scope: string;
|
|
71
|
+
payloadHex: string;
|
|
72
|
+
/** Explicit entry ID (32 hex chars). When present, enables idempotent upsert. */
|
|
73
|
+
entryId?: string;
|
|
74
|
+
/** Client-supplied monotonic counter for ID derivation when `entryId` is absent. */
|
|
75
|
+
clientSeqNo?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface DeleteDataInput {
|
|
78
|
+
orgDid: string;
|
|
79
|
+
scope: string;
|
|
80
|
+
/** Hex-encoded entry ID (32 hex chars). */
|
|
81
|
+
entryId: string;
|
|
82
|
+
}
|
|
83
|
+
export interface DeleteScopeInput {
|
|
84
|
+
orgDid: string;
|
|
85
|
+
scope: string;
|
|
86
|
+
}
|
|
87
|
+
export interface PolicyGetInput {
|
|
88
|
+
orgDid: string;
|
|
89
|
+
}
|
|
90
|
+
export interface WritersGetInput {
|
|
91
|
+
orgDid: string;
|
|
92
|
+
scope: string;
|
|
93
|
+
}
|
|
94
|
+
export interface GrantsGetInput {
|
|
95
|
+
orgDid: string;
|
|
96
|
+
contractId: string;
|
|
97
|
+
}
|
|
98
|
+
export interface DataListInput {
|
|
99
|
+
orgDid: string;
|
|
100
|
+
scope: string;
|
|
101
|
+
offset?: number;
|
|
102
|
+
limit?: number;
|
|
103
|
+
}
|
|
104
|
+
export interface DataGetInput {
|
|
105
|
+
orgDid: string;
|
|
106
|
+
scope: string;
|
|
107
|
+
/** Hex-encoded entry ID (32 hex chars). */
|
|
108
|
+
entryId: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Options used when constructing an {@link OrgDataClient}.
|
|
112
|
+
*/
|
|
113
|
+
export interface OrgDataClientOptions {
|
|
114
|
+
/** Envelope TTL in seconds applied to every call. Default: 300. */
|
|
115
|
+
ttlSecs?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Client for the user-authenticated org-data dispatch API.
|
|
119
|
+
*
|
|
120
|
+
* Constructed with the node's base URL, the caller's 32-byte ETH secret
|
|
121
|
+
* key, and the caller's DID (`did:t3n:<40-hex>`). Every method
|
|
122
|
+
* transparently fetches a fresh nonce, signs the envelope with EIP-191,
|
|
123
|
+
* and posts to `/api/org-data/execute`.
|
|
124
|
+
*
|
|
125
|
+
* The signing key must be the same key registered as an authenticator
|
|
126
|
+
* (`eth:0x<addr>`) for `userDid` in the DID registry — the service
|
|
127
|
+
* verifies this binding before dispatching any contract call.
|
|
128
|
+
*/
|
|
129
|
+
export declare class OrgDataClient {
|
|
130
|
+
private readonly baseUrl;
|
|
131
|
+
private readonly ethSecret;
|
|
132
|
+
private readonly userDid;
|
|
133
|
+
private readonly opts;
|
|
134
|
+
constructor(baseUrl: string, ethSecret: Uint8Array, userDid: string, opts?: OrgDataClientOptions);
|
|
135
|
+
private call;
|
|
136
|
+
/**
|
|
137
|
+
* Initialise the data-tier policy for an existing organisation.
|
|
138
|
+
*
|
|
139
|
+
* The calling user must be named as `initialAdminDid`. New orgs created
|
|
140
|
+
* after the org-data contract was deployed have their policy seeded
|
|
141
|
+
* automatically by the organisation contract; call this only for orgs
|
|
142
|
+
* that pre-date the contract deployment.
|
|
143
|
+
*/
|
|
144
|
+
createPolicy(input: CreatePolicyInput): Promise<MutationResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Replace the admin list and/or `max_admins` cap on an existing policy.
|
|
147
|
+
*
|
|
148
|
+
* The calling user cannot remove themselves when they are the sole
|
|
149
|
+
* remaining admin; another admin must be added first.
|
|
150
|
+
*/
|
|
151
|
+
updateMeta(input: UpdateMetaInput): Promise<MutationResponse>;
|
|
152
|
+
/**
|
|
153
|
+
* Full replacement of the writer list for a data scope.
|
|
154
|
+
*
|
|
155
|
+
* Passing an empty list removes the entry (no writers allowed).
|
|
156
|
+
* Scope names are canonicalised to lowercase before storage.
|
|
157
|
+
*/
|
|
158
|
+
setWriters(input: SetWritersInput): Promise<MutationResponse>;
|
|
159
|
+
/**
|
|
160
|
+
* Full replacement of the user-grant list for a contract.
|
|
161
|
+
*
|
|
162
|
+
* Passing an empty list removes the entry.
|
|
163
|
+
*/
|
|
164
|
+
setGrants(input: SetGrantsInput): Promise<MutationResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Delete the grant entry for a contract entirely.
|
|
167
|
+
*/
|
|
168
|
+
deleteGrants(input: DeleteGrantsInput): Promise<MutationResponse>;
|
|
169
|
+
/**
|
|
170
|
+
* Write a data entry to the org's scope.
|
|
171
|
+
*
|
|
172
|
+
* When `entryId` is supplied, the call is an idempotent upsert.
|
|
173
|
+
* When absent, `clientSeqNo` is required and the entry ID is derived
|
|
174
|
+
* via SHA-256 from `(org_did, scope, writer_did, client_seq_no)`.
|
|
175
|
+
*/
|
|
176
|
+
writeData(input: WriteDataInput): Promise<MutationResponse>;
|
|
177
|
+
/** Delete a single data entry by entry ID. */
|
|
178
|
+
deleteData(input: DeleteDataInput): Promise<MutationResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Bulk-delete all entries in a scope.
|
|
181
|
+
*
|
|
182
|
+
* Requires admin access (unlike `deleteData` which requires writer access).
|
|
183
|
+
*/
|
|
184
|
+
deleteScope(input: DeleteScopeInput): Promise<MutationResponse>;
|
|
185
|
+
/** Read the policy metadata for an org (admin-only). */
|
|
186
|
+
policyGet(input: PolicyGetInput): Promise<OrgPolicyMeta>;
|
|
187
|
+
/** Read the writer list for a scope (admin-only). */
|
|
188
|
+
writersGet(input: WritersGetInput): Promise<OrgWriters>;
|
|
189
|
+
/** Read the grant list for a contract (admin-only). */
|
|
190
|
+
grantsGet(input: GrantsGetInput): Promise<OrgContractGrants>;
|
|
191
|
+
/**
|
|
192
|
+
* List entry IDs for a scope (admin-only), paginated.
|
|
193
|
+
*
|
|
194
|
+
* Pass `offset` from the previous response's `next_offset` to fetch
|
|
195
|
+
* the next page.
|
|
196
|
+
*/
|
|
197
|
+
dataList(input: DataListInput): Promise<DataListResponse>;
|
|
198
|
+
/** Retrieve a single data entry by entry ID (admin-only). */
|
|
199
|
+
dataGet(input: DataGetInput): Promise<DataGetResponse>;
|
|
200
|
+
}
|
|
201
|
+
export { executeOrgDataAction, authenticatorIdFromEthSecret };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export type { KycStatus, KycStatusKind, KycPollOptions, KycPollCadence, } from "
|
|
|
20
20
|
export { DEFAULT_KYC_POLL_CADENCE, TERMINAL_KYC_STATUSES, KycStatusTimeoutError, } from "./types/kyc";
|
|
21
21
|
export type { OtpChannel, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, OtpMergeSuggestion, UserInputProfile, SubmitUserInputArgs, SubmitUserInputResult, UserUpsertErrorKind, } from "./types/user";
|
|
22
22
|
export { UserUpsertError } from "./types/user";
|
|
23
|
+
export { OrgDataClient } from "./client/org-data";
|
|
24
|
+
export type { OrgDataClientOptions, CreatePolicyInput, UpdateMetaInput, SetWritersInput, SetGrantsInput, DeleteGrantsInput, WriteDataInput, DeleteDataInput, DeleteScopeInput, PolicyGetInput, WritersGetInput, GrantsGetInput, DataListInput, DataGetInput, ExecuteOrgDataActionOptions, } from "./client/org-data";
|
|
25
|
+
export type { OrgDataActionWire, OrgPolicyMeta, OrgWriters, OrgContractGrants, UserGrant, EmployeeRecord, EmploymentStatus, ResidencyCategory, AgeBand, ExpenseClaim, MutationResponse, DataListResponse, DataGetResponse, } from "./types/org-data";
|
|
26
|
+
export { DelegationCustodialClient } from "./client/delegation";
|
|
27
|
+
export type { DelegationCustodialClientOpts, SignCustodialResult, } from "./client/delegation";
|
|
23
28
|
export { DELEGATION_CREDENTIAL_DOMAIN, DELEGATION_INVOCATION_DOMAIN, VC_ID_LEN, NONCE_LEN, REQUEST_HASH_LEN, AGENT_PUBKEY_LEN, ETH_SIG_LEN, buildDelegationCredential, validateCredentialBody, canonicaliseCredential, canonicaliseRequest, requestHash, buildInvocationPreimage, eip191Digest, signCredential, ethRecoverEip191, signAgentInvocation, buildPayrollInvocation, compactDidFromBytes, b64uEncodeBytes, b64uDecodeStrict, _b64uEncode, } from "./client/delegation";
|
|
24
29
|
export type { DelegationCredential, DelegationEnvelope, PayrollRunRequest, PayrollInvocation, SignDelegationResponse, BuildDelegationCredentialOpts, BuildPayrollInvocationOpts, } from "./client/delegation";
|
|
25
30
|
export { metamask_sign, metamask_get_address, eth_get_address, createDefaultHandlers, createMlKemPublicKeyHandler, createRandomHandler, } from "./client/handlers";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Org-data wire types mirroring the Rust contract shapes in
|
|
3
|
+
* `tee-contract-org-data` and `org-data-types`.
|
|
4
|
+
*
|
|
5
|
+
* Plain TypeScript interfaces (no zod) — the SDK does not use a
|
|
6
|
+
* validation library for domain types; see the existing `types/` files.
|
|
7
|
+
*
|
|
8
|
+
* Reference: `org-data-types/src/lib.rs` and
|
|
9
|
+
* `tee-contract-org-data/src/org_data.rs`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Capability grant stored under `ORG_CONTRACT_GRANTS_MAP`.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors `org_data_types::UserGrant`.
|
|
15
|
+
*/
|
|
16
|
+
export interface UserGrant {
|
|
17
|
+
/** The user this grant applies to (`did:t3n:<40-hex>`). */
|
|
18
|
+
user_did: string;
|
|
19
|
+
/** WIT function names the user may invoke (e.g. `"run-payroll"`). */
|
|
20
|
+
functions: string[];
|
|
21
|
+
/** Data scope paths the user may access (e.g. `"payroll/employees"`). */
|
|
22
|
+
scopes: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Optional key-value constraints that must match the request metadata
|
|
25
|
+
* exactly for every key present in this map.
|
|
26
|
+
*/
|
|
27
|
+
constraints: Record<string, string>;
|
|
28
|
+
/** Unix timestamp (secs) after which this grant is expired. `null` means never expires. */
|
|
29
|
+
expires_at_secs: number | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Policy record for an organisation's data tier.
|
|
33
|
+
*
|
|
34
|
+
* Mirrors `org_data_types::OrgPolicyMeta`.
|
|
35
|
+
*/
|
|
36
|
+
export interface OrgPolicyMeta {
|
|
37
|
+
/** DIDs (`did:t3n:<40-hex>`) of users authorised to manage policy and read data. */
|
|
38
|
+
admins: string[];
|
|
39
|
+
/** Maximum number of admins allowed for this org. */
|
|
40
|
+
max_admins: number;
|
|
41
|
+
/** Unix timestamp (secs) when the policy was first created. */
|
|
42
|
+
created_at_secs: number;
|
|
43
|
+
/** Unix timestamp (secs) of the most recent policy update. */
|
|
44
|
+
updated_at_secs: number;
|
|
45
|
+
}
|
|
46
|
+
export type EmploymentStatus = "Active" | "Terminated";
|
|
47
|
+
/** Singapore CPF residency categories. */
|
|
48
|
+
export type ResidencyCategory = "Citizen" | "Pr1" | "Pr2" | "PrThreePlus" | "Foreigner";
|
|
49
|
+
export type AgeBand = "Under35" | "Age35To45" | "Age45To50" | "Age50To55" | "Age55To60" | "Age60To65" | "Over65";
|
|
50
|
+
export interface ExpenseClaim {
|
|
51
|
+
claim_id: string;
|
|
52
|
+
amount_cents: number;
|
|
53
|
+
category: string;
|
|
54
|
+
description: string;
|
|
55
|
+
per_diem_days?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Employee data row stored under `OrgData[org || "payroll/employees" || entry_id]`.
|
|
59
|
+
*
|
|
60
|
+
* Mirrors `tee-contract-payroll::types::EmployeeRecord`.
|
|
61
|
+
*/
|
|
62
|
+
export interface EmployeeRecord {
|
|
63
|
+
employee_id: string;
|
|
64
|
+
employment_status: EmploymentStatus;
|
|
65
|
+
is_on_probation: boolean;
|
|
66
|
+
hire_date: string;
|
|
67
|
+
termination_date?: string;
|
|
68
|
+
/** Monthly gross base salary in integer cents SGD. */
|
|
69
|
+
base_salary_cents: number;
|
|
70
|
+
unpaid_leave_days: number;
|
|
71
|
+
working_days_in_period: number;
|
|
72
|
+
overtime_hours: number;
|
|
73
|
+
hourly_rate_cents: number;
|
|
74
|
+
residency: ResidencyCategory;
|
|
75
|
+
age_band: AgeBand;
|
|
76
|
+
expense_claims: ExpenseClaim[];
|
|
77
|
+
/** Opaque reference used by the service layer for disbursement. */
|
|
78
|
+
bank_account_ref: string;
|
|
79
|
+
bank_account_changed_recently: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Standard response returned by all policy write and data mutation operations.
|
|
83
|
+
*
|
|
84
|
+
* Mirrors `tee-contract-org-data::org_data::MutationResponse`.
|
|
85
|
+
*/
|
|
86
|
+
export interface MutationResponse {
|
|
87
|
+
/** `"created"`, `"updated"`, or `"deleted"`. */
|
|
88
|
+
status: string;
|
|
89
|
+
/** Hex-encoded entry ID; present on data write/delete operations. */
|
|
90
|
+
entry_id?: string;
|
|
91
|
+
/** Whether the target key existed before deletion; present on single-entry deletes. */
|
|
92
|
+
deleted?: boolean;
|
|
93
|
+
/** Number of entries removed; present on `org-data-delete-scope`. */
|
|
94
|
+
deleted_entries?: number;
|
|
95
|
+
tx_hash: string | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Response type alias for org-writers-get.
|
|
99
|
+
*
|
|
100
|
+
* The wire body is `{ writers: string[] }` where each entry is
|
|
101
|
+
* `did:t3n:<40-hex>`.
|
|
102
|
+
*/
|
|
103
|
+
export interface OrgWriters {
|
|
104
|
+
writers: string[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Response type alias for org-grants-get.
|
|
108
|
+
*
|
|
109
|
+
* The wire body echoes the `contract_id` alongside the grant list.
|
|
110
|
+
*/
|
|
111
|
+
export interface OrgContractGrants {
|
|
112
|
+
contract_id: string;
|
|
113
|
+
grants: UserGrant[];
|
|
114
|
+
}
|
|
115
|
+
/** Response for `org-data-list`. */
|
|
116
|
+
export interface DataListResponse {
|
|
117
|
+
/** Hex-encoded entry IDs for this page. */
|
|
118
|
+
entry_ids: string[];
|
|
119
|
+
/** Offset to pass for the next page. `null` when this is the last page. */
|
|
120
|
+
next_offset: number | null;
|
|
121
|
+
/** Total number of entries in the scope (across all pages). */
|
|
122
|
+
total: number;
|
|
123
|
+
}
|
|
124
|
+
/** Response for `org-data-get`. */
|
|
125
|
+
export interface DataGetResponse {
|
|
126
|
+
entry_id: string;
|
|
127
|
+
/** Hex-encoded raw payload bytes. */
|
|
128
|
+
payload_hex: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The signed action envelope sent to `POST /api/org-data/execute`.
|
|
132
|
+
*
|
|
133
|
+
* Field order matches `node/service/src/org_data.rs::OrgDataSignedAction`
|
|
134
|
+
* and `SignableEnvelope`. The `signature` field is the EIP-191
|
|
135
|
+
* personal_sign over the canonical JSON of the eight fields above it.
|
|
136
|
+
*/
|
|
137
|
+
export interface OrgDataActionWire {
|
|
138
|
+
nonce: string;
|
|
139
|
+
user_did: string;
|
|
140
|
+
authenticator_id: string;
|
|
141
|
+
org_did: string;
|
|
142
|
+
contract_id: string;
|
|
143
|
+
function: string;
|
|
144
|
+
args_hash: string;
|
|
145
|
+
expires_at_secs: number;
|
|
146
|
+
signature: string;
|
|
147
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terminal3/t3n-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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,6 +30,9 @@
|
|
|
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
|
+
"store-token": "tsx scripts/payroll-v2-store-token.ts",
|
|
33
36
|
"test:coverage": "vitest run --coverage",
|
|
34
37
|
"lint": "eslint src --ext .ts,.tsx",
|
|
35
38
|
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|