@opendatalabs/vana-sdk 3.3.0 → 3.4.1-canary.ba2cfd7
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.browser.d.ts +5 -3
- package/dist/index.browser.js +359 -75
- package/dist/index.browser.js.map +3 -3
- package/dist/index.node.cjs +375 -76
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +5 -3
- package/dist/index.node.js +359 -75
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs +58 -3
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +98 -6
- package/dist/protocol/eip712.js +52 -3
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow-deposit.cjs +89 -0
- package/dist/protocol/escrow-deposit.cjs.map +1 -0
- package/dist/protocol/escrow-deposit.d.ts +47 -0
- package/dist/protocol/escrow-deposit.js +60 -0
- package/dist/protocol/escrow-deposit.js.map +1 -0
- package/dist/protocol/escrow-deposit.test.d.ts +1 -0
- package/dist/protocol/escrow-flow.test.d.ts +21 -0
- package/dist/protocol/fee-registry.cjs +116 -0
- package/dist/protocol/fee-registry.cjs.map +1 -0
- package/dist/protocol/fee-registry.d.ts +151 -0
- package/dist/protocol/fee-registry.js +89 -0
- package/dist/protocol/fee-registry.js.map +1 -0
- package/dist/protocol/fee-registry.test.d.ts +1 -0
- package/dist/protocol/gateway.cjs +136 -9
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +227 -17
- package/dist/protocol/gateway.js +136 -9
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +24 -64
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +6 -13
- package/dist/protocol/grants.js +24 -63
- package/dist/protocol/grants.js.map +1 -1
- package/package.json +3 -2
|
@@ -33,7 +33,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33
33
|
owner: record.owner ?? record.ownerAddress ?? "",
|
|
34
34
|
url: record.url,
|
|
35
35
|
schemaId: record.schemaId,
|
|
36
|
-
createdAt: record.createdAt ?? record.addedAt ?? ""
|
|
36
|
+
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
37
|
+
deletedAt: record.deletedAt ?? null
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
function getMutationId(body, key) {
|
|
@@ -93,19 +94,24 @@ function createGatewayClient(baseUrl) {
|
|
|
93
94
|
}
|
|
94
95
|
return normalizeFileRecord(await unwrapEnvelope(res));
|
|
95
96
|
},
|
|
96
|
-
async listFilesSince(owner, cursor) {
|
|
97
|
+
async listFilesSince(owner, cursor, options) {
|
|
97
98
|
const params = new URLSearchParams({ user: owner });
|
|
98
99
|
if (cursor !== null) {
|
|
99
|
-
params.set("
|
|
100
|
+
params.set("cursor", cursor);
|
|
101
|
+
}
|
|
102
|
+
if (options?.includeDeleted) {
|
|
103
|
+
params.set("includeDeleted", "true");
|
|
100
104
|
}
|
|
101
105
|
const res = await fetch(`${base}/v1/files?${params.toString()}`);
|
|
102
106
|
if (!res.ok) {
|
|
103
107
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
104
108
|
}
|
|
105
|
-
const
|
|
109
|
+
const envelope = await res.json();
|
|
110
|
+
const { pagination } = envelope;
|
|
111
|
+
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
106
112
|
return {
|
|
107
|
-
files: data.files.map(normalizeFileRecord),
|
|
108
|
-
cursor:
|
|
113
|
+
files: envelope.data.files.map(normalizeFileRecord),
|
|
114
|
+
cursor: nextCursor
|
|
109
115
|
};
|
|
110
116
|
},
|
|
111
117
|
async getSchema(schemaId) {
|
|
@@ -146,6 +152,68 @@ function createGatewayClient(baseUrl) {
|
|
|
146
152
|
alreadyRegistered: false
|
|
147
153
|
};
|
|
148
154
|
},
|
|
155
|
+
async registerBuilder(params) {
|
|
156
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
headers: {
|
|
159
|
+
"Content-Type": "application/json",
|
|
160
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
161
|
+
},
|
|
162
|
+
body: JSON.stringify({
|
|
163
|
+
ownerAddress: params.ownerAddress,
|
|
164
|
+
granteeAddress: params.granteeAddress,
|
|
165
|
+
publicKey: params.publicKey,
|
|
166
|
+
appUrl: params.appUrl
|
|
167
|
+
})
|
|
168
|
+
});
|
|
169
|
+
if (res.status === 409) {
|
|
170
|
+
const body2 = await res.json().catch(() => ({}));
|
|
171
|
+
return {
|
|
172
|
+
builderId: getMutationId(
|
|
173
|
+
body2,
|
|
174
|
+
"builderId"
|
|
175
|
+
),
|
|
176
|
+
alreadyRegistered: true
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (!res.ok) {
|
|
180
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
181
|
+
}
|
|
182
|
+
const body = await res.json().catch(() => ({}));
|
|
183
|
+
return {
|
|
184
|
+
builderId: getMutationId(body, "builderId"),
|
|
185
|
+
alreadyRegistered: false
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
async registerDataPoint(params) {
|
|
189
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
190
|
+
method: "POST",
|
|
191
|
+
headers: {
|
|
192
|
+
"Content-Type": "application/json",
|
|
193
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
194
|
+
},
|
|
195
|
+
body: JSON.stringify({
|
|
196
|
+
ownerAddress: params.ownerAddress,
|
|
197
|
+
scope: params.scope,
|
|
198
|
+
dataHash: params.dataHash,
|
|
199
|
+
metadataHash: params.metadataHash,
|
|
200
|
+
expectedVersion: params.expectedVersion
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
if (!res.ok) {
|
|
204
|
+
const body2 = await res.json().catch(() => ({}));
|
|
205
|
+
const detail = body2.error ?? res.statusText;
|
|
206
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
207
|
+
}
|
|
208
|
+
const body = await res.json().catch(() => ({}));
|
|
209
|
+
return {
|
|
210
|
+
dataPointId: getMutationId(
|
|
211
|
+
body,
|
|
212
|
+
"dataPointId"
|
|
213
|
+
),
|
|
214
|
+
expectedVersion: body.expectedVersion
|
|
215
|
+
};
|
|
216
|
+
},
|
|
149
217
|
async registerFile(params) {
|
|
150
218
|
const res = await fetch(`${base}/v1/files`, {
|
|
151
219
|
method: "POST",
|
|
@@ -183,8 +251,9 @@ function createGatewayClient(baseUrl) {
|
|
|
183
251
|
body: JSON.stringify({
|
|
184
252
|
grantorAddress: params.grantorAddress,
|
|
185
253
|
granteeId: params.granteeId,
|
|
186
|
-
|
|
187
|
-
|
|
254
|
+
scopes: params.scopes,
|
|
255
|
+
grantVersion: params.grantVersion,
|
|
256
|
+
expiresAt: params.expiresAt
|
|
188
257
|
})
|
|
189
258
|
});
|
|
190
259
|
if (res.status === 409) {
|
|
@@ -209,7 +278,8 @@ function createGatewayClient(baseUrl) {
|
|
|
209
278
|
Authorization: `Web3Signed ${params.signature}`
|
|
210
279
|
},
|
|
211
280
|
body: JSON.stringify({
|
|
212
|
-
grantorAddress: params.grantorAddress
|
|
281
|
+
grantorAddress: params.grantorAddress,
|
|
282
|
+
grantVersion: params.grantVersion
|
|
213
283
|
})
|
|
214
284
|
});
|
|
215
285
|
if (res.status === 409) return;
|
|
@@ -217,6 +287,63 @@ function createGatewayClient(baseUrl) {
|
|
|
217
287
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
218
288
|
}
|
|
219
289
|
},
|
|
290
|
+
async getEscrowBalance(account) {
|
|
291
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
292
|
+
if (!res.ok) {
|
|
293
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
294
|
+
}
|
|
295
|
+
return await res.json();
|
|
296
|
+
},
|
|
297
|
+
async submitEscrowDeposit(params) {
|
|
298
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
299
|
+
method: "POST",
|
|
300
|
+
headers: { "Content-Type": "application/json" },
|
|
301
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
302
|
+
});
|
|
303
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
304
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
305
|
+
}
|
|
306
|
+
return await res.json();
|
|
307
|
+
},
|
|
308
|
+
async payForOperation(params) {
|
|
309
|
+
const body = {
|
|
310
|
+
payerAddress: params.payerAddress,
|
|
311
|
+
opType: params.opType,
|
|
312
|
+
opId: params.opId,
|
|
313
|
+
asset: params.asset,
|
|
314
|
+
amount: params.amount,
|
|
315
|
+
paymentNonce: params.paymentNonce
|
|
316
|
+
};
|
|
317
|
+
if (params.accessRecord) {
|
|
318
|
+
body["accessRecord"] = params.accessRecord;
|
|
319
|
+
}
|
|
320
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
321
|
+
method: "POST",
|
|
322
|
+
headers: {
|
|
323
|
+
"Content-Type": "application/json",
|
|
324
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
325
|
+
},
|
|
326
|
+
body: JSON.stringify(body)
|
|
327
|
+
});
|
|
328
|
+
if (!res.ok) {
|
|
329
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
330
|
+
}
|
|
331
|
+
return await res.json();
|
|
332
|
+
},
|
|
333
|
+
async settle(params) {
|
|
334
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
335
|
+
method: "POST",
|
|
336
|
+
headers: { "Content-Type": "application/json" },
|
|
337
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
338
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
339
|
+
// doesn't have to deal with an undefined.
|
|
340
|
+
body: JSON.stringify(params ?? {})
|
|
341
|
+
});
|
|
342
|
+
if (!res.ok) {
|
|
343
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
344
|
+
}
|
|
345
|
+
return await res.json();
|
|
346
|
+
},
|
|
220
347
|
async deleteFile(params) {
|
|
221
348
|
const res = await fetch(`${base}/v1/files/${params.fileId}`, {
|
|
222
349
|
method: "DELETE",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/protocol/gateway.ts"],"sourcesContent":["export interface GatewayEnvelope<T> {\n data: T;\n proof: GatewayProof;\n}\n\nexport interface GatewayProof {\n signature: string;\n timestamp: string;\n gatewayAddress: string;\n requestHash: string;\n responseHash: string;\n userSignature: string;\n status: string;\n chainBlockHeight: number;\n}\n\nexport interface Builder {\n id: string;\n ownerAddress: string;\n granteeAddress: string;\n publicKey: string;\n appUrl: string;\n addedAt: string;\n}\n\nexport interface Schema {\n id: string;\n ownerAddress: string;\n name: string;\n definitionUrl: string;\n scope: string;\n addedAt: string;\n}\n\nexport interface ServerInfo {\n id: string;\n ownerAddress: string;\n serverAddress: string;\n publicKey: string;\n serverUrl: string;\n addedAt: string;\n}\n\nexport interface GatewayGrantResponse {\n id: string;\n grantorAddress: string;\n granteeId: string;\n grant: string;\n fileIds: string[];\n status: \"pending\" | \"confirmed\";\n addedAt: string;\n revokedAt: string | null;\n revocationSignature: string | null;\n}\n\nexport interface GrantListItem {\n id: string;\n grantorAddress: string;\n granteeId: string;\n grant: string;\n fileIds: string[];\n status: \"pending\" | \"confirmed\";\n addedAt: string;\n revokedAt: string | null;\n revocationSignature: string | null;\n}\n\nexport interface FileRecord {\n fileId: string;\n owner: string;\n url: string;\n schemaId: string;\n createdAt: string;\n}\n\nexport interface FileListResult {\n files: FileRecord[];\n cursor: string | null;\n}\n\ninterface GatewayFileRecord {\n id?: string;\n fileId?: string;\n ownerAddress?: string;\n owner?: string;\n url: string;\n schemaId: string;\n addedAt?: string;\n createdAt?: string;\n}\n\nexport interface RegisterFileParams {\n ownerAddress: string;\n url: string;\n schemaId: string;\n signature: string;\n}\n\nexport interface CreateGrantParams {\n grantorAddress: string;\n granteeId: string;\n grant: string;\n fileIds: string[];\n signature: string;\n}\n\nexport interface RevokeGrantParams {\n grantId: string;\n grantorAddress: string;\n signature: string;\n}\n\nexport interface DeleteFileParams {\n fileId: string;\n ownerAddress: string;\n /** EIP-712 FileDeletion signature, signed by the owner or the owner's registered server. */\n signature: string;\n}\n\nexport interface RegisterServerParams {\n ownerAddress: string;\n serverAddress: string;\n publicKey: string;\n serverUrl: string;\n signature: string;\n}\n\nexport interface RegisterServerResult {\n serverId?: string;\n alreadyRegistered: boolean;\n}\n\nexport interface GatewayClient {\n isRegisteredBuilder(address: string): Promise<boolean>;\n getBuilder(address: string): Promise<Builder | null>;\n getGrant(grantId: string): Promise<GatewayGrantResponse | null>;\n listGrantsByUser(userAddress: string): Promise<GrantListItem[]>;\n getSchemaForScope(scope: string): Promise<Schema | null>;\n getServer(address: string): Promise<ServerInfo | null>;\n getFile(fileId: string): Promise<FileRecord | null>;\n listFilesSince(owner: string, cursor: string | null): Promise<FileListResult>;\n getSchema(schemaId: string): Promise<Schema | null>;\n registerServer(params: RegisterServerParams): Promise<RegisterServerResult>;\n registerFile(params: RegisterFileParams): Promise<{ fileId?: string }>;\n createGrant(params: CreateGrantParams): Promise<{ grantId?: string }>;\n revokeGrant(params: RevokeGrantParams): Promise<void>;\n /**\n * Soft-deletes (de-registers) a file at the gateway. Resolves on 200 and on 409\n * (already deleted) — 409 is treated as idempotent success. Other non-2xx, including\n * 404 (file not registered), throw; the PS delete cascade decides whether a 404 is\n * benign (blob already gone) or a hard failure.\n */\n deleteFile(params: DeleteFileParams): Promise<void>;\n}\n\nexport function createGatewayClient(baseUrl: string): GatewayClient {\n const base = baseUrl.replace(/\\/+$/, \"\");\n\n async function unwrapEnvelope<T>(res: Response): Promise<T> {\n const envelope = (await res.json()) as GatewayEnvelope<T>;\n return envelope.data;\n }\n\n function normalizeFileRecord(record: GatewayFileRecord): FileRecord {\n return {\n fileId: record.fileId ?? record.id ?? \"\",\n owner: record.owner ?? record.ownerAddress ?? \"\",\n url: record.url,\n schemaId: record.schemaId,\n createdAt: record.createdAt ?? record.addedAt ?? \"\",\n };\n }\n\n function getMutationId(\n body: Record<string, unknown>,\n key: string,\n ): string | undefined {\n const value = body[key] ?? body[\"id\"];\n return typeof value === \"string\" ? value : undefined;\n }\n\n return {\n async isRegisteredBuilder(address: string): Promise<boolean> {\n const builder = await this.getBuilder(address);\n return builder !== null;\n },\n\n async getBuilder(address: string): Promise<Builder | null> {\n const res = await fetch(`${base}/v1/builders/${address}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Builder>(res);\n },\n\n async getGrant(grantId: string): Promise<GatewayGrantResponse | null> {\n const res = await fetch(`${base}/v1/grants/${grantId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<GatewayGrantResponse>(res);\n },\n\n async listGrantsByUser(userAddress: string): Promise<GrantListItem[]> {\n const res = await fetch(`${base}/v1/grants?user=${userAddress}`);\n if (res.status === 404) return [];\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<GrantListItem[]>(res);\n },\n\n async getSchemaForScope(scope: string): Promise<Schema | null> {\n const res = await fetch(`${base}/v1/schemas?scope=${scope}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Schema>(res);\n },\n\n async getServer(address: string): Promise<ServerInfo | null> {\n const res = await fetch(`${base}/v1/servers/${address}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<ServerInfo>(res);\n },\n\n async getFile(fileId: string): Promise<FileRecord | null> {\n const res = await fetch(`${base}/v1/files/${fileId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return normalizeFileRecord(await unwrapEnvelope<GatewayFileRecord>(res));\n },\n\n async listFilesSince(\n owner: string,\n cursor: string | null,\n ): Promise<FileListResult> {\n const params = new URLSearchParams({ user: owner });\n if (cursor !== null) {\n params.set(\"since\", cursor);\n }\n const res = await fetch(`${base}/v1/files?${params.toString()}`);\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const data = await unwrapEnvelope<{\n files: GatewayFileRecord[];\n cursor: string | null;\n }>(res);\n return {\n files: data.files.map(normalizeFileRecord),\n cursor: data.cursor,\n };\n },\n\n async getSchema(schemaId: string): Promise<Schema | null> {\n const res = await fetch(`${base}/v1/schemas/${schemaId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Schema>(res);\n },\n\n async registerServer(\n params: RegisterServerParams,\n ): Promise<RegisterServerResult> {\n const res = await fetch(`${base}/v1/servers`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n serverAddress: params.serverAddress,\n publicKey: params.publicKey,\n serverUrl: params.serverUrl,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n serverId: getMutationId(body as Record<string, unknown>, \"serverId\"),\n alreadyRegistered: true,\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json().catch(() => ({}));\n return {\n serverId: getMutationId(body as Record<string, unknown>, \"serverId\"),\n alreadyRegistered: false,\n };\n },\n\n async registerFile(\n params: RegisterFileParams,\n ): Promise<{ fileId?: string }> {\n const res = await fetch(`${base}/v1/files`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n url: params.url,\n schemaId: params.schemaId,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n fileId: getMutationId(body as Record<string, unknown>, \"fileId\"),\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json();\n return {\n fileId: getMutationId(body as Record<string, unknown>, \"fileId\"),\n };\n },\n\n async createGrant(\n params: CreateGrantParams,\n ): Promise<{ grantId?: string }> {\n const res = await fetch(`${base}/v1/grants`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n grantorAddress: params.grantorAddress,\n granteeId: params.granteeId,\n grant: params.grant,\n fileIds: params.fileIds,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n grantId: getMutationId(body as Record<string, unknown>, \"grantId\"),\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json();\n return {\n grantId: getMutationId(body as Record<string, unknown>, \"grantId\"),\n };\n },\n\n async revokeGrant(params: RevokeGrantParams): Promise<void> {\n const res = await fetch(`${base}/v1/grants/${params.grantId}`, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n grantorAddress: params.grantorAddress,\n }),\n });\n if (res.status === 409) return;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n },\n\n async deleteFile(params: DeleteFileParams): Promise<void> {\n const res = await fetch(`${base}/v1/files/${params.fileId}`, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n }),\n });\n // 409 = already deleted; treat as success (idempotent), same as revokeGrant.\n if (res.status === 409) return;\n if (!res.ok) {\n throw new Error(`Gateway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CAAC;AAAA,MACH,CAAC;AAED,UAAI,IAAI,WAAW,IAAK;AACxB,UAAI,CAAC,IAAI,IAAI;AACX,cAAM,IAAI,MAAM,kBAAkB,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,MAClE;AAAA,IACF;AAAA,EACF;AACF;","names":["body"]}
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/gateway.ts"],"sourcesContent":["export interface GatewayEnvelope<T> {\n data: T;\n proof: GatewayProof;\n /**\n * Cursor-based pagination metadata, present on list endpoints (e.g.\n * `GET /v1/files`). A sibling of `data`, not nested inside it — so callers\n * that need it must read the full envelope rather than going through\n * `unwrapEnvelope`, which intentionally returns only `data`.\n */\n pagination?: GatewayPagination;\n}\n\nexport interface GatewayPagination {\n limit: number;\n hasMore: boolean;\n /**\n * Opaque cursor for the NEXT page; pass back as the `cursor` query param.\n * Null when there are no further pages.\n */\n nextCursor: string | null;\n}\n\nexport interface GatewayProof {\n signature: string;\n timestamp: string;\n gatewayAddress: string;\n requestHash: string;\n responseHash: string;\n userSignature: string;\n status: string;\n chainBlockHeight: number;\n}\n\nexport interface Builder {\n id: string;\n ownerAddress: string;\n granteeAddress: string;\n publicKey: string;\n appUrl: string;\n addedAt: string;\n}\n\nexport interface Schema {\n id: string;\n ownerAddress: string;\n name: string;\n definitionUrl: string;\n scope: string;\n addedAt: string;\n}\n\nexport interface ServerInfo {\n id: string;\n ownerAddress: string;\n serverAddress: string;\n publicKey: string;\n serverUrl: string;\n addedAt: string;\n // ISO timestamp when the grantor deregistered this server, null while\n // active. The gateway returns this on /v1/servers/:address GETs since\n // covering revocation in the response keeps the attestation hash\n // authoritative for both states.\n revokedAt: string | null;\n}\n\n// Fee annotation surfaced on every GET grant response. Amounts are decimal\n// uint256 strings to match `/v1/escrow/pay`'s wire format. totalDue is a\n// snapshot — the gateway re-resolves fees at pay time, so clients shouldn't\n// cache this across requests.\nexport interface GatewayGrantFee {\n asset: string;\n registrationFee: string;\n dataAccessFee: string;\n totalDue: string;\n}\n\n// Lifecycle of a grant's on-chain settlement, tracked separately from the\n// fee-payment lifecycle (paymentStatus). Driven by POST /v1/settle:\n// pending — nothing on-chain yet\n// submitting — settle tx broadcast but receipt not yet observed\n// confirmed — settle tx mined successfully\n// finalized — finalized tip past the settle block, reorg-safe\n// reorged — finalized observation reverted; back to 'pending' on next settle\nexport type GatewayGrantStatus =\n | \"pending\"\n | \"submitting\"\n | \"confirmed\"\n | \"finalized\"\n | \"reorged\";\n\nexport interface GatewayGrantResponse {\n id: string;\n grantorAddress: string;\n granteeId: string;\n scopes: string[];\n status: GatewayGrantStatus;\n addedAt: string;\n // Grantor-signed deadline. null = perpetual grant (signed value was 0).\n expiresAt: string | null;\n // Derived at read time from expiresAt vs the gateway's clock — a snapshot,\n // not a cached truth. Re-check against expiresAt locally if you care.\n expired: boolean;\n revokedAt: string | null;\n revocationSignature: string | null;\n // 'pending' until the grant registration fee is settled via /v1/escrow/pay.\n paymentStatus: \"pending\" | \"paid\";\n paidAt: string | null;\n paidBy: string | null;\n // Decimal-string uint256 monotonic nonce; advances on every state change.\n grantVersion: string;\n // Settle metadata — populated as the grant progresses through the chain\n // lifecycle. Null while `status === 'pending'`.\n settleTxHash: string | null;\n settleSubmittedAt: string | null;\n // Revocation metadata — populated independently when the grantor signs\n // and the gateway pushes a deregister tx.\n revocationTxHash: string | null;\n revocationSubmittedAt: string | null;\n fee: GatewayGrantFee;\n}\n\nexport type GrantListItem = GatewayGrantResponse;\n\nexport interface FileRecord {\n fileId: string;\n owner: string;\n url: string;\n schemaId: string;\n createdAt: string;\n /**\n * Soft-deletion timestamp (ISO 8601), or null if the file is active. Always present\n * (`normalizeFileRecord` populates it); non-null only when the gateway returns deletion state\n * (e.g. listed with `includeDeleted`). Drives the PS sync delete-reconciliation.\n */\n deletedAt: string | null;\n}\n\nexport interface FileListResult {\n files: FileRecord[];\n cursor: string | null;\n}\n\nexport interface ListFilesOptions {\n /**\n * Include soft-deleted files in the result (each carries a non-null `deletedAt`). Default false.\n * Used by the PS sync download worker to reconcile deletions of files it already holds locally.\n */\n includeDeleted?: boolean;\n}\n\ninterface GatewayFileRecord {\n id?: string;\n fileId?: string;\n ownerAddress?: string;\n owner?: string;\n url: string;\n schemaId: string;\n addedAt?: string;\n createdAt?: string;\n deletedAt?: string | null;\n}\n\nexport interface RegisterFileParams {\n ownerAddress: string;\n url: string;\n schemaId: string;\n signature: string;\n}\n\n// grantVersion and expiresAt are decimal-string uint256s — same wire format\n// the gateway expects. The caller is responsible for converting their bigint\n// to a decimal string and for signing GRANT_REGISTRATION_TYPES with matching\n// bigint values.\nexport interface CreateGrantParams {\n grantorAddress: string;\n granteeId: string;\n scopes: string[];\n grantVersion: string;\n expiresAt: string;\n signature: string;\n}\n\nexport interface RevokeGrantParams {\n grantId: string;\n grantorAddress: string;\n grantVersion: string;\n signature: string;\n}\n\nexport interface DeleteFileParams {\n fileId: string;\n ownerAddress: string;\n /** EIP-712 FileDeletion signature, signed by the owner or the owner's registered server. */\n signature: string;\n}\n\nexport interface RegisterServerParams {\n ownerAddress: string;\n serverAddress: string;\n publicKey: string;\n serverUrl: string;\n signature: string;\n}\n\nexport interface RegisterServerResult {\n serverId?: string;\n alreadyRegistered: boolean;\n}\n\nexport interface RegisterBuilderParams {\n ownerAddress: string;\n // Wallet the builder authenticates to the Personal Server with. The\n // builderId is deterministically derived from (owner, grantee, publicKey,\n // appUrl) so this triple pins the on-chain identity.\n granteeAddress: string;\n publicKey: string;\n appUrl: string;\n signature: string;\n}\n\nexport interface RegisterBuilderResult {\n builderId?: string;\n alreadyRegistered: boolean;\n}\n\n// AddData on DataRegistryV2. dataHash + metadataHash are bytes32 commitments\n// to the off-chain payload + its metadata. expectedVersion is a CAS knob —\n// the gateway/contract rejects on 409 if a higher version is already stored,\n// and the error body surfaces `currentExpectedVersion` so callers can re-sign.\nexport interface RegisterDataPointParams {\n ownerAddress: string;\n scope: string;\n dataHash: string;\n metadataHash: string;\n expectedVersion: string;\n signature: string;\n}\n\nexport interface RegisterDataPointResult {\n dataPointId?: string;\n expectedVersion?: string;\n}\n\n// ── Escrow / data-access payment path ───────────────────────────────────────\n// /v1/escrow/pay debits the payer's escrow balance for a payable op. For a\n// grant: opType = 'grant', opId = the bytes32 grantId. amount, paymentNonce,\n// and asset are decimal-uint256 strings on the wire. The signature is the\n// raw EIP-712 hex of GENERIC_PAYMENT_TYPES against escrowPaymentDomain.\n\n// A server-signed delivery receipt attached to a data-access payment. The\n// signature is over RECORD_DATA_ACCESS_TYPES against dataRegistryDomain; the\n// signer must be a personal server the data point's owner has registered as\n// trusted. The gateway re-uses this signature verbatim on-chain in the next\n// /v1/settle pass via DataRegistryV2.recordDataAccess, where `recordId`\n// dedupes via `_usedRecordIds`.\nexport interface AccessRecord {\n dataPointId: string;\n // Decimal-string uint256 — the data point version being attested to.\n version: string;\n // Must equal the enclosing payment's payerAddress (the gateway enforces).\n accessor: string;\n recordId: string;\n signature: string;\n}\n\nexport interface PayForOperationParams {\n payerAddress: string;\n opType: string;\n opId: string;\n asset: string;\n amount: string;\n // Per-payer monotonic; (payer, nonce, kind) must be unique. The gateway\n // returns 409 if reused — bump and re-sign.\n paymentNonce: string;\n signature: string;\n // Optional: attach a server-signed access record so the next /v1/settle\n // pass submits a recordDataAccess tx alongside the payment settlement.\n // Required for data-access payments (the second-and-onward payments per\n // grant) that want their on-chain `totalAccesses` counter to advance.\n accessRecord?: AccessRecord;\n}\n\nexport interface PayForOperationResult {\n opType: string;\n opId: string;\n payerAddress: string;\n asset: string;\n amount: string;\n // Echoes how the gateway split this payment. `registrationPaid` is true on\n // the first payment for a grant (which bundles both fees) and false on\n // subsequent data-access-only payments. Off-chain ledger state only — the\n // on-chain settlement of the registration is tracked by the grant's\n // `status` field, not this flag.\n breakdown: {\n registrationFee: string;\n dataAccessFee: string;\n registrationPaid: boolean;\n };\n paymentNonce: string;\n paidAt: string;\n}\n\n// ── Settle / reconcile ──────────────────────────────────────────────────────\n// POST /v1/settle drains pending-on-chain rows (grants, servers, data points,\n// access records) to the relayer, then promotes 'submitting' → 'confirmed'\n// and 'confirmed' → 'finalized' for previously-submitted rows. One call does\n// all three; the response surfaces each phase's outcomes.\n\n// The four op-types the settle endpoint knows about. Kept as a union so\n// callers can narrow inside the discriminated SettleItem shape.\nexport type SettleOpType = \"grant\" | \"server\" | \"data\" | \"access\";\n\nexport type SettleItem =\n | {\n opType: SettleOpType;\n opId: string;\n // 'confirmed' when the submit function waited for the receipt and it\n // mined (registerAndSettle path); 'submitting' when only the tx was\n // sent (no receipt wait).\n status: \"submitting\" | \"confirmed\";\n settleTxHash: string | null;\n settleSubmittedAt: string | null;\n // Block height the tx mined in; only set when status === 'confirmed'.\n chainBlockHeight: string | null;\n revocationTxHash: string | null;\n revocationSubmittedAt: string | null;\n // True while lib/settle.ts is in placeholder mode for this row's pass.\n placeholder: boolean;\n }\n | {\n opType: SettleOpType;\n opId: string;\n status: \"skipped\";\n reason: string;\n }\n | {\n opType: SettleOpType;\n opId: string;\n status: \"failed\";\n error: string;\n };\n\n// Outcome of the housekeeping pass that retries earlier `submitting` rows\n// whose receipt arrived after the prior /v1/settle's wait budget elapsed.\nexport interface SettlePromoteResult {\n opType: SettleOpType;\n opId: string;\n status: \"confirmed\" | \"failed\" | \"pending\" | \"skipped\";\n txHash: string;\n chainBlockHeight: string | null;\n reason?: string;\n}\n\n// Outcome of the reconcile pass that advances 'confirmed' → 'finalized' once\n// the chain's finalized tip catches up past the tx's block (or reverts to\n// 'pending' on reorg detection).\nexport interface SettleReconcileItem {\n opId: string;\n status: \"finalized\" | \"reorged\" | \"unchanged\";\n chainBlockHeight: string | null;\n settleTxHash: string | null;\n reason?: string;\n}\n\nexport interface SettleParams {\n // Per-phase cap. Bounded by MAX_LIMIT on the gateway side; omit to use\n // the gateway's default BATCH_LIMIT.\n limit?: number;\n}\n\nexport interface SettleResult {\n scanned: number;\n submitted: number;\n confirmed: number;\n skipped: number;\n failed: number;\n items: SettleItem[];\n promoted: { count: number; items: SettlePromoteResult[] };\n reconciled: {\n scanned: number;\n finalized: number;\n reorged: number;\n unchanged: number;\n items: SettleReconcileItem[];\n };\n // Present only when the gateway is configured for paced submission —\n // spreads work across several blocks within one /v1/settle invocation.\n paced?: { iterations: number };\n}\n\n// /v1/escrow/balance?account=... — pure read. Returns finalized balances by\n// asset, plus the lifecycle breakdown of deposits.\nexport interface EscrowBalanceEntry {\n asset: string;\n // Gross credited deposits for (account, asset). Decremented only when the\n // reconcile pass marks a payment finalized — NOT on /v1/escrow/pay.\n balance: string;\n // Sum of claimedAmount for deposits still in 'submitted' status — surfaced\n // separately so clients don't conflate \"credited\" with \"deposit announced\n // but not yet confirmed.\"\n pendingAmount: string;\n // Sum of payments.amount for (account, asset) regardless of settled status —\n // mirrors the /v1/escrow/pay handler's soft-lock counter. Subtract from\n // `balance` to see how much the payer can still authorise.\n authorizedAmount: string;\n // `max(balance − authorizedAmount, 0)`. The headroom a payer has against\n // the soft-lock before /v1/escrow/pay starts returning 402.\n availableAmount: string;\n updatedAt: string | null;\n}\n\nexport interface EscrowDepositSubmitted {\n txHash: string;\n submittedAt: string;\n claimedAsset: string;\n claimedAmount: string;\n}\n\nexport interface EscrowDepositFinalized {\n txHash: string;\n finalizedAt: string | null;\n blockNumber: string | null;\n claimedAsset: string;\n claimedAmount: string;\n}\n\nexport interface EscrowDepositFailed {\n txHash: string;\n submittedAt: string;\n claimedAsset: string;\n claimedAmount: string;\n lastError: string | null;\n}\n\nexport interface EscrowBalance {\n account: string;\n balances: EscrowBalanceEntry[];\n deposits: {\n submitted: EscrowDepositSubmitted[];\n finalized: EscrowDepositFinalized[];\n failed: EscrowDepositFailed[];\n };\n}\n\n// /v1/escrow/deposit announces an on-chain deposit tx so the gateway can\n// reconcile it into the payer's balance. The gateway extracts the credited\n// account from calldata — no off-chain claim about who paid.\nexport interface SubmitDepositParams {\n txHash: string;\n}\n\nexport interface DepositState {\n txHash: string;\n account: string;\n // 'submitted' | 'finalized' | 'failed' — kept open since the gateway adds\n // states (e.g. 'orphaned') as the deposit flow evolves.\n status: string;\n blockNumber: string | null;\n submittedAt: string;\n finalizedAt: string | null;\n lastError: string | null;\n}\n\nexport interface GatewayClient {\n isRegisteredBuilder(address: string): Promise<boolean>;\n getBuilder(address: string): Promise<Builder | null>;\n getGrant(grantId: string): Promise<GatewayGrantResponse | null>;\n listGrantsByUser(userAddress: string): Promise<GrantListItem[]>;\n getSchemaForScope(scope: string): Promise<Schema | null>;\n getServer(address: string): Promise<ServerInfo | null>;\n getFile(fileId: string): Promise<FileRecord | null>;\n listFilesSince(\n owner: string,\n cursor: string | null,\n options?: ListFilesOptions,\n ): Promise<FileListResult>;\n getSchema(schemaId: string): Promise<Schema | null>;\n registerServer(params: RegisterServerParams): Promise<RegisterServerResult>;\n registerBuilder(\n params: RegisterBuilderParams,\n ): Promise<RegisterBuilderResult>;\n registerDataPoint(\n params: RegisterDataPointParams,\n ): Promise<RegisterDataPointResult>;\n registerFile(params: RegisterFileParams): Promise<{ fileId?: string }>;\n createGrant(params: CreateGrantParams): Promise<{ grantId?: string }>;\n revokeGrant(params: RevokeGrantParams): Promise<void>;\n getEscrowBalance(account: string): Promise<EscrowBalance>;\n submitEscrowDeposit(params: SubmitDepositParams): Promise<DepositState>;\n payForOperation(\n params: PayForOperationParams,\n ): Promise<PayForOperationResult>;\n settle(params?: SettleParams): Promise<SettleResult>;\n /**\n * Soft-deletes (de-registers) a file at the gateway. Resolves on 200 and on 409\n * (already deleted) — 409 is treated as idempotent success. Other non-2xx, including\n * 404 (file not registered), throw; the PS delete cascade decides whether a 404 is\n * benign (blob already gone) or a hard failure.\n */\n deleteFile(params: DeleteFileParams): Promise<void>;\n}\n\nexport function createGatewayClient(baseUrl: string): GatewayClient {\n const base = baseUrl.replace(/\\/+$/, \"\");\n\n async function unwrapEnvelope<T>(res: Response): Promise<T> {\n const envelope = (await res.json()) as GatewayEnvelope<T>;\n return envelope.data;\n }\n\n function normalizeFileRecord(record: GatewayFileRecord): FileRecord {\n return {\n fileId: record.fileId ?? record.id ?? \"\",\n owner: record.owner ?? record.ownerAddress ?? \"\",\n url: record.url,\n schemaId: record.schemaId,\n createdAt: record.createdAt ?? record.addedAt ?? \"\",\n deletedAt: record.deletedAt ?? null,\n };\n }\n\n function getMutationId(\n body: Record<string, unknown>,\n key: string,\n ): string | undefined {\n const value = body[key] ?? body[\"id\"];\n return typeof value === \"string\" ? value : undefined;\n }\n\n return {\n async isRegisteredBuilder(address: string): Promise<boolean> {\n const builder = await this.getBuilder(address);\n return builder !== null;\n },\n\n async getBuilder(address: string): Promise<Builder | null> {\n const res = await fetch(`${base}/v1/builders/${address}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Builder>(res);\n },\n\n async getGrant(grantId: string): Promise<GatewayGrantResponse | null> {\n const res = await fetch(`${base}/v1/grants/${grantId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<GatewayGrantResponse>(res);\n },\n\n async listGrantsByUser(userAddress: string): Promise<GrantListItem[]> {\n const res = await fetch(`${base}/v1/grants?user=${userAddress}`);\n if (res.status === 404) return [];\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<GrantListItem[]>(res);\n },\n\n async getSchemaForScope(scope: string): Promise<Schema | null> {\n const res = await fetch(`${base}/v1/schemas?scope=${scope}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Schema>(res);\n },\n\n async getServer(address: string): Promise<ServerInfo | null> {\n const res = await fetch(`${base}/v1/servers/${address}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<ServerInfo>(res);\n },\n\n async getFile(fileId: string): Promise<FileRecord | null> {\n const res = await fetch(`${base}/v1/files/${fileId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return normalizeFileRecord(await unwrapEnvelope<GatewayFileRecord>(res));\n },\n\n async listFilesSince(\n owner: string,\n cursor: string | null,\n options?: ListFilesOptions,\n ): Promise<FileListResult> {\n const params = new URLSearchParams({ user: owner });\n if (cursor !== null) {\n params.set(\"cursor\", cursor);\n }\n if (options?.includeDeleted) {\n params.set(\"includeDeleted\", \"true\");\n }\n const res = await fetch(`${base}/v1/files?${params.toString()}`);\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n // The next-page cursor lives in the envelope's `pagination.nextCursor`\n // (a sibling of `data`), so read the full envelope rather than going\n // through `unwrapEnvelope`, which returns only `data`. Fall back to a\n // legacy `data.cursor` for older gateways that nested it there.\n const envelope = (await res.json()) as GatewayEnvelope<{\n files: GatewayFileRecord[];\n cursor?: string | null;\n }>;\n const { pagination } = envelope;\n const nextCursor =\n pagination?.hasMore === false\n ? null\n : (pagination?.nextCursor ?? envelope.data.cursor ?? null);\n return {\n files: envelope.data.files.map(normalizeFileRecord),\n cursor: nextCursor,\n };\n },\n\n async getSchema(schemaId: string): Promise<Schema | null> {\n const res = await fetch(`${base}/v1/schemas/${schemaId}`);\n if (res.status === 404) return null;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return unwrapEnvelope<Schema>(res);\n },\n\n async registerServer(\n params: RegisterServerParams,\n ): Promise<RegisterServerResult> {\n const res = await fetch(`${base}/v1/servers`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n serverAddress: params.serverAddress,\n publicKey: params.publicKey,\n serverUrl: params.serverUrl,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n serverId: getMutationId(body as Record<string, unknown>, \"serverId\"),\n alreadyRegistered: true,\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json().catch(() => ({}));\n return {\n serverId: getMutationId(body as Record<string, unknown>, \"serverId\"),\n alreadyRegistered: false,\n };\n },\n\n async registerBuilder(\n params: RegisterBuilderParams,\n ): Promise<RegisterBuilderResult> {\n const res = await fetch(`${base}/v1/builders`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n granteeAddress: params.granteeAddress,\n publicKey: params.publicKey,\n appUrl: params.appUrl,\n }),\n });\n // 409 is idempotent — the gateway's current 409 body doesn't include\n // the builderId, but we tolerate it in case that changes (mirrors the\n // registerServer / createGrant shape).\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n builderId: getMutationId(\n body as Record<string, unknown>,\n \"builderId\",\n ),\n alreadyRegistered: true,\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json().catch(() => ({}));\n return {\n builderId: getMutationId(body as Record<string, unknown>, \"builderId\"),\n alreadyRegistered: false,\n };\n },\n\n async registerDataPoint(\n params: RegisterDataPointParams,\n ): Promise<RegisterDataPointResult> {\n const res = await fetch(`${base}/v1/data`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n scope: params.scope,\n dataHash: params.dataHash,\n metadataHash: params.metadataHash,\n expectedVersion: params.expectedVersion,\n }),\n });\n // 409 is a real failure here (stale CAS), not an idempotent replay —\n // surface the gateway's error message verbatim so the caller knows\n // what `currentExpectedVersion` to re-sign against.\n if (!res.ok) {\n const body = (await res.json().catch(() => ({}))) as {\n error?: string;\n };\n const detail = body.error ?? res.statusText;\n throw new Error(`Gateway error: ${res.status} ${detail}`);\n }\n const body = (await res.json().catch(() => ({}))) as {\n dataPointId?: string;\n expectedVersion?: string;\n };\n return {\n dataPointId: getMutationId(\n body as Record<string, unknown>,\n \"dataPointId\",\n ),\n expectedVersion: body.expectedVersion,\n };\n },\n\n async registerFile(\n params: RegisterFileParams,\n ): Promise<{ fileId?: string }> {\n const res = await fetch(`${base}/v1/files`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n url: params.url,\n schemaId: params.schemaId,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n fileId: getMutationId(body as Record<string, unknown>, \"fileId\"),\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json();\n return {\n fileId: getMutationId(body as Record<string, unknown>, \"fileId\"),\n };\n },\n\n async createGrant(\n params: CreateGrantParams,\n ): Promise<{ grantId?: string }> {\n const res = await fetch(`${base}/v1/grants`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n grantorAddress: params.grantorAddress,\n granteeId: params.granteeId,\n scopes: params.scopes,\n grantVersion: params.grantVersion,\n expiresAt: params.expiresAt,\n }),\n });\n if (res.status === 409) {\n const body = await res.json().catch(() => ({}));\n return {\n grantId: getMutationId(body as Record<string, unknown>, \"grantId\"),\n };\n }\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n const body = await res.json();\n return {\n grantId: getMutationId(body as Record<string, unknown>, \"grantId\"),\n };\n },\n\n async revokeGrant(params: RevokeGrantParams): Promise<void> {\n const res = await fetch(`${base}/v1/grants/${params.grantId}`, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n grantorAddress: params.grantorAddress,\n grantVersion: params.grantVersion,\n }),\n });\n if (res.status === 409) return;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n },\n\n async getEscrowBalance(account: string): Promise<EscrowBalance> {\n const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n // Unlike the rest of /v1, the balance endpoint returns the body\n // directly (no GatewayEnvelope wrap) — it's a pure read with no\n // gateway-signed attestation. See data-gateway api/v1/escrow/balance.ts.\n return (await res.json()) as EscrowBalance;\n },\n\n async submitEscrowDeposit(\n params: SubmitDepositParams,\n ): Promise<DepositState> {\n const res = await fetch(`${base}/v1/escrow/deposit`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ txHash: params.txHash }),\n });\n // The gateway returns 202 for \"accepted (still confirming)\" and 200 for\n // duplicate idempotent replays. Both carry the deposit's current state.\n if (res.status !== 200 && res.status !== 202) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as DepositState;\n },\n\n async payForOperation(\n params: PayForOperationParams,\n ): Promise<PayForOperationResult> {\n // Build the body without the accessRecord key when absent so the\n // gateway's \"missing optional\" branch matches the no-receipt case\n // exactly (an explicit `accessRecord: undefined` would JSON-serialize\n // to nothing — same result — but keeping it conditional makes wire\n // traces easier to read).\n const body: Record<string, unknown> = {\n payerAddress: params.payerAddress,\n opType: params.opType,\n opId: params.opId,\n asset: params.asset,\n amount: params.amount,\n paymentNonce: params.paymentNonce,\n };\n if (params.accessRecord) {\n body[\"accessRecord\"] = params.accessRecord;\n }\n const res = await fetch(`${base}/v1/escrow/pay`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify(body),\n });\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as PayForOperationResult;\n },\n\n async settle(params?: SettleParams): Promise<SettleResult> {\n const res = await fetch(`${base}/v1/settle`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n // The gateway accepts an empty body; only `limit` is recognised.\n // Always send a JSON body so the gateway's req.body shape parse\n // doesn't have to deal with an undefined.\n body: JSON.stringify(params ?? {}),\n });\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n return (await res.json()) as SettleResult;\n },\n\n async deleteFile(params: DeleteFileParams): Promise<void> {\n const res = await fetch(`${base}/v1/files/${params.fileId}`, {\n method: \"DELETE\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Web3Signed ${params.signature}`,\n },\n body: JSON.stringify({\n ownerAddress: params.ownerAddress,\n }),\n });\n // 409 = already deleted; treat as success (idempotent), same as revokeGrant.\n if (res.status === 409) return;\n if (!res.ok) {\n throw new Error(`Gateway error: ${res.status} ${res.statusText}`);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsfO,SAAS,oBAAoB,SAAgC;AAClE,QAAM,OAAO,QAAQ,QAAQ,QAAQ,EAAE;AAEvC,iBAAe,eAAkB,KAA2B;AAC1D,UAAM,WAAY,MAAM,IAAI,KAAK;AACjC,WAAO,SAAS;AAAA,EAClB;AAEA,WAAS,oBAAoB,QAAuC;AAClE,WAAO;AAAA,MACL,QAAQ,OAAO,UAAU,OAAO,MAAM;AAAA,MACtC,OAAO,OAAO,SAAS,OAAO,gBAAgB;AAAA,MAC9C,KAAK,OAAO;AAAA,MACZ,UAAU,OAAO;AAAA,MACjB,WAAW,OAAO,aAAa,OAAO,WAAW;AAAA,MACjD,WAAW,OAAO,aAAa;AAAA,IACjC;AAAA,EACF;AAEA,WAAS,cACP,MACA,KACoB;AACpB,UAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI;AACpC,WAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,EAC7C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,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,MAClE;AACA,aAAQ,MAAM,IAAI,KAAK;AAAA,IACzB;AAAA,IAEA,MAAM,WAAW,QAAyC;AACxD,YAAM,MAAM,MAAM,MAAM,GAAG,IAAI,aAAa,OAAO,MAAM,IAAI;AAAA,QAC3D,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,cAAc,OAAO,SAAS;AAAA,QAC/C;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,cAAc,OAAO;AAAA,QACvB,CAAC;AAAA,MACH,CAAC;AAED,UAAI,IAAI,WAAW,IAAK;AACxB,UAAI,CAAC,IAAI,IAAI;AACX,cAAM,IAAI,MAAM,kBAAkB,IAAI,MAAM,IAAI,IAAI,UAAU,EAAE;AAAA,MAClE;AAAA,IACF;AAAA,EACF;AACF;","names":["body"]}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
export interface GatewayEnvelope<T> {
|
|
2
2
|
data: T;
|
|
3
3
|
proof: GatewayProof;
|
|
4
|
+
/**
|
|
5
|
+
* Cursor-based pagination metadata, present on list endpoints (e.g.
|
|
6
|
+
* `GET /v1/files`). A sibling of `data`, not nested inside it — so callers
|
|
7
|
+
* that need it must read the full envelope rather than going through
|
|
8
|
+
* `unwrapEnvelope`, which intentionally returns only `data`.
|
|
9
|
+
*/
|
|
10
|
+
pagination?: GatewayPagination;
|
|
11
|
+
}
|
|
12
|
+
export interface GatewayPagination {
|
|
13
|
+
limit: number;
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Opaque cursor for the NEXT page; pass back as the `cursor` query param.
|
|
17
|
+
* Null when there are no further pages.
|
|
18
|
+
*/
|
|
19
|
+
nextCursor: string | null;
|
|
4
20
|
}
|
|
5
21
|
export interface GatewayProof {
|
|
6
22
|
signature: string;
|
|
@@ -35,40 +51,61 @@ export interface ServerInfo {
|
|
|
35
51
|
publicKey: string;
|
|
36
52
|
serverUrl: string;
|
|
37
53
|
addedAt: string;
|
|
38
|
-
}
|
|
39
|
-
export interface GatewayGrantResponse {
|
|
40
|
-
id: string;
|
|
41
|
-
grantorAddress: string;
|
|
42
|
-
granteeId: string;
|
|
43
|
-
grant: string;
|
|
44
|
-
fileIds: string[];
|
|
45
|
-
status: "pending" | "confirmed";
|
|
46
|
-
addedAt: string;
|
|
47
54
|
revokedAt: string | null;
|
|
48
|
-
revocationSignature: string | null;
|
|
49
55
|
}
|
|
50
|
-
export interface
|
|
56
|
+
export interface GatewayGrantFee {
|
|
57
|
+
asset: string;
|
|
58
|
+
registrationFee: string;
|
|
59
|
+
dataAccessFee: string;
|
|
60
|
+
totalDue: string;
|
|
61
|
+
}
|
|
62
|
+
export type GatewayGrantStatus = "pending" | "submitting" | "confirmed" | "finalized" | "reorged";
|
|
63
|
+
export interface GatewayGrantResponse {
|
|
51
64
|
id: string;
|
|
52
65
|
grantorAddress: string;
|
|
53
66
|
granteeId: string;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
status: "pending" | "confirmed";
|
|
67
|
+
scopes: string[];
|
|
68
|
+
status: GatewayGrantStatus;
|
|
57
69
|
addedAt: string;
|
|
70
|
+
expiresAt: string | null;
|
|
71
|
+
expired: boolean;
|
|
58
72
|
revokedAt: string | null;
|
|
59
73
|
revocationSignature: string | null;
|
|
74
|
+
paymentStatus: "pending" | "paid";
|
|
75
|
+
paidAt: string | null;
|
|
76
|
+
paidBy: string | null;
|
|
77
|
+
grantVersion: string;
|
|
78
|
+
settleTxHash: string | null;
|
|
79
|
+
settleSubmittedAt: string | null;
|
|
80
|
+
revocationTxHash: string | null;
|
|
81
|
+
revocationSubmittedAt: string | null;
|
|
82
|
+
fee: GatewayGrantFee;
|
|
60
83
|
}
|
|
84
|
+
export type GrantListItem = GatewayGrantResponse;
|
|
61
85
|
export interface FileRecord {
|
|
62
86
|
fileId: string;
|
|
63
87
|
owner: string;
|
|
64
88
|
url: string;
|
|
65
89
|
schemaId: string;
|
|
66
90
|
createdAt: string;
|
|
91
|
+
/**
|
|
92
|
+
* Soft-deletion timestamp (ISO 8601), or null if the file is active. Always present
|
|
93
|
+
* (`normalizeFileRecord` populates it); non-null only when the gateway returns deletion state
|
|
94
|
+
* (e.g. listed with `includeDeleted`). Drives the PS sync delete-reconciliation.
|
|
95
|
+
*/
|
|
96
|
+
deletedAt: string | null;
|
|
67
97
|
}
|
|
68
98
|
export interface FileListResult {
|
|
69
99
|
files: FileRecord[];
|
|
70
100
|
cursor: string | null;
|
|
71
101
|
}
|
|
102
|
+
export interface ListFilesOptions {
|
|
103
|
+
/**
|
|
104
|
+
* Include soft-deleted files in the result (each carries a non-null `deletedAt`). Default false.
|
|
105
|
+
* Used by the PS sync download worker to reconcile deletions of files it already holds locally.
|
|
106
|
+
*/
|
|
107
|
+
includeDeleted?: boolean;
|
|
108
|
+
}
|
|
72
109
|
export interface RegisterFileParams {
|
|
73
110
|
ownerAddress: string;
|
|
74
111
|
url: string;
|
|
@@ -78,13 +115,15 @@ export interface RegisterFileParams {
|
|
|
78
115
|
export interface CreateGrantParams {
|
|
79
116
|
grantorAddress: string;
|
|
80
117
|
granteeId: string;
|
|
81
|
-
|
|
82
|
-
|
|
118
|
+
scopes: string[];
|
|
119
|
+
grantVersion: string;
|
|
120
|
+
expiresAt: string;
|
|
83
121
|
signature: string;
|
|
84
122
|
}
|
|
85
123
|
export interface RevokeGrantParams {
|
|
86
124
|
grantId: string;
|
|
87
125
|
grantorAddress: string;
|
|
126
|
+
grantVersion: string;
|
|
88
127
|
signature: string;
|
|
89
128
|
}
|
|
90
129
|
export interface DeleteFileParams {
|
|
@@ -104,6 +143,171 @@ export interface RegisterServerResult {
|
|
|
104
143
|
serverId?: string;
|
|
105
144
|
alreadyRegistered: boolean;
|
|
106
145
|
}
|
|
146
|
+
export interface RegisterBuilderParams {
|
|
147
|
+
ownerAddress: string;
|
|
148
|
+
granteeAddress: string;
|
|
149
|
+
publicKey: string;
|
|
150
|
+
appUrl: string;
|
|
151
|
+
signature: string;
|
|
152
|
+
}
|
|
153
|
+
export interface RegisterBuilderResult {
|
|
154
|
+
builderId?: string;
|
|
155
|
+
alreadyRegistered: boolean;
|
|
156
|
+
}
|
|
157
|
+
export interface RegisterDataPointParams {
|
|
158
|
+
ownerAddress: string;
|
|
159
|
+
scope: string;
|
|
160
|
+
dataHash: string;
|
|
161
|
+
metadataHash: string;
|
|
162
|
+
expectedVersion: string;
|
|
163
|
+
signature: string;
|
|
164
|
+
}
|
|
165
|
+
export interface RegisterDataPointResult {
|
|
166
|
+
dataPointId?: string;
|
|
167
|
+
expectedVersion?: string;
|
|
168
|
+
}
|
|
169
|
+
export interface AccessRecord {
|
|
170
|
+
dataPointId: string;
|
|
171
|
+
version: string;
|
|
172
|
+
accessor: string;
|
|
173
|
+
recordId: string;
|
|
174
|
+
signature: string;
|
|
175
|
+
}
|
|
176
|
+
export interface PayForOperationParams {
|
|
177
|
+
payerAddress: string;
|
|
178
|
+
opType: string;
|
|
179
|
+
opId: string;
|
|
180
|
+
asset: string;
|
|
181
|
+
amount: string;
|
|
182
|
+
paymentNonce: string;
|
|
183
|
+
signature: string;
|
|
184
|
+
accessRecord?: AccessRecord;
|
|
185
|
+
}
|
|
186
|
+
export interface PayForOperationResult {
|
|
187
|
+
opType: string;
|
|
188
|
+
opId: string;
|
|
189
|
+
payerAddress: string;
|
|
190
|
+
asset: string;
|
|
191
|
+
amount: string;
|
|
192
|
+
breakdown: {
|
|
193
|
+
registrationFee: string;
|
|
194
|
+
dataAccessFee: string;
|
|
195
|
+
registrationPaid: boolean;
|
|
196
|
+
};
|
|
197
|
+
paymentNonce: string;
|
|
198
|
+
paidAt: string;
|
|
199
|
+
}
|
|
200
|
+
export type SettleOpType = "grant" | "server" | "data" | "access";
|
|
201
|
+
export type SettleItem = {
|
|
202
|
+
opType: SettleOpType;
|
|
203
|
+
opId: string;
|
|
204
|
+
status: "submitting" | "confirmed";
|
|
205
|
+
settleTxHash: string | null;
|
|
206
|
+
settleSubmittedAt: string | null;
|
|
207
|
+
chainBlockHeight: string | null;
|
|
208
|
+
revocationTxHash: string | null;
|
|
209
|
+
revocationSubmittedAt: string | null;
|
|
210
|
+
placeholder: boolean;
|
|
211
|
+
} | {
|
|
212
|
+
opType: SettleOpType;
|
|
213
|
+
opId: string;
|
|
214
|
+
status: "skipped";
|
|
215
|
+
reason: string;
|
|
216
|
+
} | {
|
|
217
|
+
opType: SettleOpType;
|
|
218
|
+
opId: string;
|
|
219
|
+
status: "failed";
|
|
220
|
+
error: string;
|
|
221
|
+
};
|
|
222
|
+
export interface SettlePromoteResult {
|
|
223
|
+
opType: SettleOpType;
|
|
224
|
+
opId: string;
|
|
225
|
+
status: "confirmed" | "failed" | "pending" | "skipped";
|
|
226
|
+
txHash: string;
|
|
227
|
+
chainBlockHeight: string | null;
|
|
228
|
+
reason?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface SettleReconcileItem {
|
|
231
|
+
opId: string;
|
|
232
|
+
status: "finalized" | "reorged" | "unchanged";
|
|
233
|
+
chainBlockHeight: string | null;
|
|
234
|
+
settleTxHash: string | null;
|
|
235
|
+
reason?: string;
|
|
236
|
+
}
|
|
237
|
+
export interface SettleParams {
|
|
238
|
+
limit?: number;
|
|
239
|
+
}
|
|
240
|
+
export interface SettleResult {
|
|
241
|
+
scanned: number;
|
|
242
|
+
submitted: number;
|
|
243
|
+
confirmed: number;
|
|
244
|
+
skipped: number;
|
|
245
|
+
failed: number;
|
|
246
|
+
items: SettleItem[];
|
|
247
|
+
promoted: {
|
|
248
|
+
count: number;
|
|
249
|
+
items: SettlePromoteResult[];
|
|
250
|
+
};
|
|
251
|
+
reconciled: {
|
|
252
|
+
scanned: number;
|
|
253
|
+
finalized: number;
|
|
254
|
+
reorged: number;
|
|
255
|
+
unchanged: number;
|
|
256
|
+
items: SettleReconcileItem[];
|
|
257
|
+
};
|
|
258
|
+
paced?: {
|
|
259
|
+
iterations: number;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export interface EscrowBalanceEntry {
|
|
263
|
+
asset: string;
|
|
264
|
+
balance: string;
|
|
265
|
+
pendingAmount: string;
|
|
266
|
+
authorizedAmount: string;
|
|
267
|
+
availableAmount: string;
|
|
268
|
+
updatedAt: string | null;
|
|
269
|
+
}
|
|
270
|
+
export interface EscrowDepositSubmitted {
|
|
271
|
+
txHash: string;
|
|
272
|
+
submittedAt: string;
|
|
273
|
+
claimedAsset: string;
|
|
274
|
+
claimedAmount: string;
|
|
275
|
+
}
|
|
276
|
+
export interface EscrowDepositFinalized {
|
|
277
|
+
txHash: string;
|
|
278
|
+
finalizedAt: string | null;
|
|
279
|
+
blockNumber: string | null;
|
|
280
|
+
claimedAsset: string;
|
|
281
|
+
claimedAmount: string;
|
|
282
|
+
}
|
|
283
|
+
export interface EscrowDepositFailed {
|
|
284
|
+
txHash: string;
|
|
285
|
+
submittedAt: string;
|
|
286
|
+
claimedAsset: string;
|
|
287
|
+
claimedAmount: string;
|
|
288
|
+
lastError: string | null;
|
|
289
|
+
}
|
|
290
|
+
export interface EscrowBalance {
|
|
291
|
+
account: string;
|
|
292
|
+
balances: EscrowBalanceEntry[];
|
|
293
|
+
deposits: {
|
|
294
|
+
submitted: EscrowDepositSubmitted[];
|
|
295
|
+
finalized: EscrowDepositFinalized[];
|
|
296
|
+
failed: EscrowDepositFailed[];
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
export interface SubmitDepositParams {
|
|
300
|
+
txHash: string;
|
|
301
|
+
}
|
|
302
|
+
export interface DepositState {
|
|
303
|
+
txHash: string;
|
|
304
|
+
account: string;
|
|
305
|
+
status: string;
|
|
306
|
+
blockNumber: string | null;
|
|
307
|
+
submittedAt: string;
|
|
308
|
+
finalizedAt: string | null;
|
|
309
|
+
lastError: string | null;
|
|
310
|
+
}
|
|
107
311
|
export interface GatewayClient {
|
|
108
312
|
isRegisteredBuilder(address: string): Promise<boolean>;
|
|
109
313
|
getBuilder(address: string): Promise<Builder | null>;
|
|
@@ -112,9 +316,11 @@ export interface GatewayClient {
|
|
|
112
316
|
getSchemaForScope(scope: string): Promise<Schema | null>;
|
|
113
317
|
getServer(address: string): Promise<ServerInfo | null>;
|
|
114
318
|
getFile(fileId: string): Promise<FileRecord | null>;
|
|
115
|
-
listFilesSince(owner: string, cursor: string | null): Promise<FileListResult>;
|
|
319
|
+
listFilesSince(owner: string, cursor: string | null, options?: ListFilesOptions): Promise<FileListResult>;
|
|
116
320
|
getSchema(schemaId: string): Promise<Schema | null>;
|
|
117
321
|
registerServer(params: RegisterServerParams): Promise<RegisterServerResult>;
|
|
322
|
+
registerBuilder(params: RegisterBuilderParams): Promise<RegisterBuilderResult>;
|
|
323
|
+
registerDataPoint(params: RegisterDataPointParams): Promise<RegisterDataPointResult>;
|
|
118
324
|
registerFile(params: RegisterFileParams): Promise<{
|
|
119
325
|
fileId?: string;
|
|
120
326
|
}>;
|
|
@@ -122,6 +328,10 @@ export interface GatewayClient {
|
|
|
122
328
|
grantId?: string;
|
|
123
329
|
}>;
|
|
124
330
|
revokeGrant(params: RevokeGrantParams): Promise<void>;
|
|
331
|
+
getEscrowBalance(account: string): Promise<EscrowBalance>;
|
|
332
|
+
submitEscrowDeposit(params: SubmitDepositParams): Promise<DepositState>;
|
|
333
|
+
payForOperation(params: PayForOperationParams): Promise<PayForOperationResult>;
|
|
334
|
+
settle(params?: SettleParams): Promise<SettleResult>;
|
|
125
335
|
/**
|
|
126
336
|
* Soft-deletes (de-registers) a file at the gateway. Resolves on 200 and on 409
|
|
127
337
|
* (already deleted) — 409 is treated as idempotent success. Other non-2xx, including
|