@terminal3/t3n-sdk 4.7.0 → 4.9.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/cli/index.js +1 -1
- package/dist/index.d.ts +115 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2272,6 +2272,33 @@ declare class T3nClient {
|
|
|
2272
2272
|
* a JSON array.
|
|
2273
2273
|
*/
|
|
2274
2274
|
getWalletHistory(walletAddress: string): Promise<unknown[]>;
|
|
2275
|
+
/**
|
|
2276
|
+
* Return the organisations the authenticated user is a member of, as
|
|
2277
|
+
* canonical `did:t3n:<40-hex>` strings.
|
|
2278
|
+
*
|
|
2279
|
+
* Backed by `tee:user/my-organisations`, which reads the caller's
|
|
2280
|
+
* membership set (`UserOrganisations`) keyed on the session DID — the
|
|
2281
|
+
* request carries no body, and a user cannot query anyone else's
|
|
2282
|
+
* memberships. An **empty array means the user belongs to no
|
|
2283
|
+
* organisation**; this is the intended signal for an org-scoped app to
|
|
2284
|
+
* gate entry on (authentication itself is org-agnostic — a user in no
|
|
2285
|
+
* org still authenticates successfully).
|
|
2286
|
+
*
|
|
2287
|
+
* Note this reflects *affiliation*, not per-contract authorisation:
|
|
2288
|
+
* membership does not by itself grant admin rights or a scope grant.
|
|
2289
|
+
* Org-scoped operations remain gated server-side (403) on the org's
|
|
2290
|
+
* admin list / grants regardless of what this returns.
|
|
2291
|
+
*
|
|
2292
|
+
* `my-organisations` is an additive export, so any registered
|
|
2293
|
+
* user-contract version exposes it; {@link executeUserContract}
|
|
2294
|
+
* resolves `"latest"` to the current version so this wrapper doesn't
|
|
2295
|
+
* drift on every `CONTRACT_VERSION` bump.
|
|
2296
|
+
*
|
|
2297
|
+
* @returns the caller's organisation DIDs (`did:t3n:<40-hex>`), possibly empty.
|
|
2298
|
+
* @throws if unauthenticated, if the node rejects the action, or if the
|
|
2299
|
+
* response shape is unexpected.
|
|
2300
|
+
*/
|
|
2301
|
+
myOrgs(): Promise<Did[]>;
|
|
2275
2302
|
/**
|
|
2276
2303
|
* Remove the authenticated user's account AND explicitly abandon
|
|
2277
2304
|
* any wallets. Writes `Abandoned` audit rows to wallet history,
|
|
@@ -3178,6 +3205,92 @@ declare function formatTokens(baseUnits: number | bigint): string;
|
|
|
3178
3205
|
*/
|
|
3179
3206
|
declare function toBaseUnits(tokens: number): number;
|
|
3180
3207
|
|
|
3208
|
+
/**
|
|
3209
|
+
* SessionUsageReportClient — typed wrapper over the authenticated
|
|
3210
|
+
* `/api/rpc` + `action.execute` pipeline for the per-organisation usage
|
|
3211
|
+
* report served by `tee:admin/contracts#org-usage-report`.
|
|
3212
|
+
*
|
|
3213
|
+
* Unlike the cluster-admin `metering.usage-report` action (reached over
|
|
3214
|
+
* `POST /api/admin` with an EIP-191 cluster-admin signature), this export
|
|
3215
|
+
* is authenticated on the caller's ordinary session DID: the node stamps
|
|
3216
|
+
* the proven `authenticated_did` into the contract context, and the
|
|
3217
|
+
* contract returns the signed report ONLY when that DID is in the
|
|
3218
|
+
* requested org's admin set. An org admin can therefore fetch **only their
|
|
3219
|
+
* own org's** usage.
|
|
3220
|
+
*
|
|
3221
|
+
* Mirrors {@link SessionOrgDataClient}: it accepts a caller-owned
|
|
3222
|
+
* {@link T3nClient} that the caller has already driven through
|
|
3223
|
+
* `handshake()` and `authenticate()` (e.g. the SIWE flow the orgs admin UI
|
|
3224
|
+
* uses). The constructor performs no auth lifecycle of its own.
|
|
3225
|
+
*/
|
|
3226
|
+
|
|
3227
|
+
interface OrgUsageReportInput {
|
|
3228
|
+
/**
|
|
3229
|
+
* Owning organisation DID (`did:t3n:<40hex>` or bare 40-hex). The
|
|
3230
|
+
* authenticated caller MUST be an admin of this org, else the contract
|
|
3231
|
+
* refuses with a `not_org_admin:` error.
|
|
3232
|
+
*/
|
|
3233
|
+
orgDid: string;
|
|
3234
|
+
/** Inclusive window start (cluster-timestamp ms). */
|
|
3235
|
+
fromMs: number;
|
|
3236
|
+
/** Exclusive window end (cluster-timestamp ms). Must be > `fromMs`. */
|
|
3237
|
+
toMs: number;
|
|
3238
|
+
/** Optional cap on rows scanned; `truncated` is set on the reply when hit. */
|
|
3239
|
+
maxScan?: number;
|
|
3240
|
+
}
|
|
3241
|
+
/** Signature envelope on the signed report (secp256k1 cluster key). */
|
|
3242
|
+
interface UsageReportSignature {
|
|
3243
|
+
alg: string;
|
|
3244
|
+
/** Signer eth address, derived from the returned pubkey (never the request). */
|
|
3245
|
+
node_id: string;
|
|
3246
|
+
payload_hash: string;
|
|
3247
|
+
sig: unknown;
|
|
3248
|
+
pub_key: unknown;
|
|
3249
|
+
}
|
|
3250
|
+
/**
|
|
3251
|
+
* The `completed` envelope returned by `org-usage-report`. Identical shape
|
|
3252
|
+
* to the cluster-admin `metering.usage-report` reply. The signed report
|
|
3253
|
+
* body itself is the base64 `report_b64` (JCS-canonical bytes the
|
|
3254
|
+
* `signature` attests to).
|
|
3255
|
+
*/
|
|
3256
|
+
interface OrgUsageReport {
|
|
3257
|
+
status: string;
|
|
3258
|
+
report_id: string;
|
|
3259
|
+
org_did: string;
|
|
3260
|
+
from_ms: number;
|
|
3261
|
+
to_ms: number;
|
|
3262
|
+
report_b64: string;
|
|
3263
|
+
signature: UsageReportSignature;
|
|
3264
|
+
truncated: boolean;
|
|
3265
|
+
}
|
|
3266
|
+
declare function isOrgUsageReport(v: unknown): v is OrgUsageReport;
|
|
3267
|
+
/**
|
|
3268
|
+
* Session-authenticated client for the per-org usage report.
|
|
3269
|
+
*
|
|
3270
|
+
* @see SessionOrgDataClient for the precondition contract — the supplied
|
|
3271
|
+
* {@link T3nClient} must already be handshaken + authenticated; the
|
|
3272
|
+
* runtime guard only catches the no-handshake case.
|
|
3273
|
+
*/
|
|
3274
|
+
declare class SessionUsageReportClient {
|
|
3275
|
+
private readonly t3n;
|
|
3276
|
+
private readonly baseUrl;
|
|
3277
|
+
constructor(t3n: T3nClient, baseUrl: string);
|
|
3278
|
+
/**
|
|
3279
|
+
* Fetch the signed usage report for an org the caller administers.
|
|
3280
|
+
*
|
|
3281
|
+
* Refuses with `not_org_admin: ...` when the authenticated session DID
|
|
3282
|
+
* is not in the org's admin set — an org admin can only read their own
|
|
3283
|
+
* org's usage.
|
|
3284
|
+
*/
|
|
3285
|
+
getOrgUsageReport(input: OrgUsageReportInput): Promise<OrgUsageReport>;
|
|
3286
|
+
}
|
|
3287
|
+
/**
|
|
3288
|
+
* Construct a {@link SessionUsageReportClient} from a caller-owned
|
|
3289
|
+
* {@link T3nClient} that has already been driven through `handshake()` and
|
|
3290
|
+
* `authenticate()`.
|
|
3291
|
+
*/
|
|
3292
|
+
declare function createUsageReportClientFromSession(t3n: T3nClient, baseUrl: string): SessionUsageReportClient;
|
|
3293
|
+
|
|
3181
3294
|
/** Closed-vocabulary serialisation annotations for a contract function's body. */
|
|
3182
3295
|
interface WireBlock {
|
|
3183
3296
|
/**
|
|
@@ -3778,5 +3891,5 @@ declare function tenantDidHex(tenantDid: string): string;
|
|
|
3778
3891
|
declare function validateTail(tail: string): string;
|
|
3779
3892
|
declare function canonicalTenantName(tenantDid: string, tail: string): string;
|
|
3780
3893
|
|
|
3781
|
-
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, WireEncodingError, 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, isUnsafeTrustServer, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
|
|
3782
|
-
export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, 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, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
|
|
3894
|
+
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, SessionUsageReportClient, T3nClient, 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, bytesToString, canonicalTenantName, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isUnsafeTrustServer, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
|
|
3895
|
+
export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, Logger, MapCreateInput, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ReaderSet, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
|