import { type GrantPermission } from "./scope-actions.js"; import type { EscrowBalanceResult } from "./escrow.js"; export type { EscrowBalanceEntry, EscrowBalanceResult, FailedDepositEntry as EscrowDepositFailed, FinalizedDepositEntry as EscrowDepositFinalized, SubmittedDepositEntry as EscrowDepositSubmitted, } from "./escrow.js"; export interface GatewayEnvelope { data: T; proof: GatewayProof; /** * Cursor-based pagination metadata, present on list endpoints (e.g. * `GET /v1/data`). A sibling of `data`, not nested inside it — so callers * that need it must read the full envelope rather than going through * `unwrapEnvelope`, which intentionally returns only `data`. */ pagination?: GatewayPagination; } export interface GatewayPagination { limit: number; hasMore: boolean; /** * Opaque cursor for the NEXT page; pass back as the `cursor` query param. * Null when there are no further pages. */ nextCursor: string | null; } export interface GatewayProof { signature: string; timestamp: string; gatewayAddress: string; requestHash: string; responseHash: string; userSignature: string; status: string; chainBlockHeight: number; } export interface Builder { id: string; ownerAddress: string; granteeAddress: string; publicKey: string; appUrl: string; addedAt: string; } export interface Schema { id: string; ownerAddress: string; name: string; definitionUrl: string; scope: string; addedAt: string; } export interface OwnerServerRecord { id: string; ownerAddress: string; serverAddress: string; publicKey: string; serverUrl: string; status: string; chainBlockHeight: string | null; addedAt: string; revokedAt: string | null; } export interface OwnerServersResult { active: OwnerServerRecord[]; revoked: OwnerServerRecord[]; count: number; } export interface ServerInfo { id: string; ownerAddress: string; serverAddress: string; publicKey: string; serverUrl: string; addedAt: string; revokedAt: string | null; } export interface GatewayGrantFee { asset: string; registrationFee: string; dataAccessFee: string; totalDue: string; } export type GatewayGrantStatus = "pending" | "submitting" | "confirmed" | "finalized" | "reorged"; export interface GatewayGrantResponse { id: string; grantorAddress: string; granteeId: string; scopes: string[]; permissions?: GrantPermission[]; status: GatewayGrantStatus; addedAt: string; expiresAt: string | null; expired: boolean; revokedAt: string | null; revocationSignature: string | null; paymentStatus: "pending" | "paid"; paidAt: string | null; paidBy: string | null; grantVersion: string; settleTxHash: string | null; settleSubmittedAt: string | null; revocationTxHash: string | null; revocationSubmittedAt: string | null; fee: GatewayGrantFee; } export type GrantListItem = GatewayGrantResponse; export interface DataPointRecord { id: string; ownerAddress: string; scope: string; dataHash: string; metadataHash: string; expectedVersion: string; addedAt: string; deletedAt?: string | null; } export interface GetDataPointOptions { /** * Return the row even after it was deleted (with `deletedAt` set and the * tombstone hash pair) instead of throwing `DataPointDeletedError`. */ includeDeleted?: boolean; } export interface DataPointListResult { dataPoints: DataPointRecord[]; cursor: string | null; } export interface ListDataPointsOptions { /** * Only return rows added at or after this ISO 8601 timestamp. Used by sync * loops that want incremental tails — pass the last seen `addedAt`. */ since?: string; /** Page size. Capped at 1000 by the gateway. */ limit?: number; /** * Include deleted (tombstoned) rows, each carrying `deletedAt`. Off by * default; without it the SDK also drops any tombstone the gateway leaks. */ includeDeleted?: boolean; } export interface CreateGrantParams { grantorAddress: string; granteeId: string; scopes: string[]; grantVersion: string; expiresAt: string; signature: string; } export interface RevokeGrantParams { grantId: string; grantorAddress: string; grantVersion: string; signature: string; } export interface RegisterServerParams { ownerAddress: string; serverAddress: string; publicKey: string; serverUrl: string; signature: string; } export interface RegisterServerResult { serverId?: string; alreadyRegistered: boolean; } export interface RegisterBuilderParams { ownerAddress: string; granteeAddress: string; publicKey: string; appUrl: string; signature: string; } export interface RegisterBuilderResult { builderId?: string; alreadyRegistered: boolean; } export interface RegisterDataPointParams { ownerAddress: string; scope: string; dataHash: string; metadataHash: string; expectedVersion: string; signature: string; } export interface RegisterDataPointResult { dataPointId?: string; expectedVersion?: string; } export interface DeleteDataPointParams { ownerAddress: string; scope: string; expectedVersion: string; signature: string; } export interface DeleteDataPointResult { dataPointId?: string; ownerAddress?: string; scope?: string; dataHash?: string; metadataHash?: string; expectedVersion?: string; deletedAt?: string | null; } export interface AccessRecord { dataPointId: string; version: string; accessor: string; recordId: string; signature: string; } export interface PayForOperationParams { payerAddress: string; opType: string; opId: string; asset: string; amount: string; paymentNonce: string; signature: string; accessRecord?: AccessRecord; } export interface PayForOperationResult { opType: string; opId: string; payerAddress: string; asset: string; amount: string; breakdown: { registrationFee: string; dataAccessFee: string; registrationPaid: boolean; }; paymentNonce: string; paidAt: string; } export type SettleOpType = "grant" | "server" | "data" | "access" | "builder" | "data-status"; export type SettleItem = { opType: SettleOpType; opId: string; status: "submitting" | "confirmed"; settleTxHash: string | null; settleSubmittedAt: string | null; chainBlockHeight: string | null; revocationTxHash: string | null; revocationSubmittedAt: string | null; placeholder: boolean; } | { opType: SettleOpType; opId: string; status: "skipped"; reason: string; } | { opType: SettleOpType; opId: string; status: "failed"; error: string; }; export interface SettlePromoteResult { opType: SettleOpType; opId: string; status: "confirmed" | "failed" | "pending" | "skipped"; txHash: string; chainBlockHeight: string | null; reason?: string; } export interface SettleReconcileItem { opId: string; status: "finalized" | "reorged" | "unchanged"; chainBlockHeight: string | null; settleTxHash: string | null; reason?: string; } export interface SettleParams { limit?: number; } export interface SettleResult { scanned: number; submitted: number; confirmed: number; skipped: number; failed: number; items: SettleItem[]; promoted: { count: number; items: SettlePromoteResult[]; }; reconciled: { scanned: number; finalized: number; reorged: number; unchanged: number; items: SettleReconcileItem[]; }; paced?: { iterations: number; }; } /** * Legacy `GatewayClient` name for the canonical `/v1/escrow/balance` response. * `availableAmount` is `max(balance − authorizedAmount − withdrawingAmount, 0)`. */ export type EscrowBalance = EscrowBalanceResult; export interface SubmitDepositParams { txHash: string; } export interface DepositState { txHash: string; account: string; status: string; blockNumber: string | null; submittedAt: string; finalizedAt: string | null; lastError: string | null; } export interface GatewayClient { isRegisteredBuilder(address: string): Promise; getBuilder(address: string): Promise; getGrant(grantId: string): Promise; listGrantsByUser(userAddress: string): Promise; getSchemaForScope(scope: string): Promise; getServer(address: string): Promise; /** * List every personal server an owner has registered — split into `active` * (currently trusted) and `revoked` (deregistered). Each list is ordered * newest-first; `active[0]` is the sensible default when the caller just * needs one URL for the owner. Empty owner returns `{active: [], revoked: [], count: 0}`. * Discovery-only endpoint — no per-server attestation; use `getServer` for that. */ listServersByOwner(owner: string): Promise; /** * Fetch a single data point by its deterministic id (keccak256 of (owner, scope)). * Returns null on 404. Throws `DataPointDeletedError` on 410, or when the row is a * tombstone, unless `options.includeDeleted` is set. The gateway omits `status` from * the response body -- read it from the on-chain DataRegistryV2 contract when you need * the canonical lifecycle state. */ getDataPoint(dataPointId: string, options?: GetDataPointOptions): Promise; /** * Page through an owner's data points. Cursor is opaque; pass `null` for the first * page and feed back `result.cursor` until it returns null. * Deleted rows are excluded unless `options.includeDeleted` is set. */ listDataPointsByOwner(owner: string, cursor: string | null, options?: ListDataPointsOptions): Promise; getSchema(schemaId: string): Promise; registerServer(params: RegisterServerParams): Promise; registerBuilder(params: RegisterBuilderParams): Promise; registerDataPoint(params: RegisterDataPointParams): Promise; /** * Tombstone a data point: `DELETE /v1/data/:dataPointId` with the owner's * AddData signature for version `current + 1`. The dataPointId is derived * from (ownerAddress, scope). Throws `DataPointVersionConflictError` on * 409, `DataPointDeletedError` on 410 (already deleted), * `DataPointNotFoundError` on 404. */ deleteDataPoint(params: DeleteDataPointParams): Promise; createGrant(params: CreateGrantParams): Promise<{ grantId?: string; }>; revokeGrant(params: RevokeGrantParams): Promise; getEscrowBalance(account: string): Promise; submitEscrowDeposit(params: SubmitDepositParams): Promise; payForOperation(params: PayForOperationParams): Promise; settle(params?: SettleParams): Promise; } export declare function createGatewayClient(baseUrl: string): GatewayClient;