From 17995b3cfcc82b3f3cc6b1bac71c479e7e0ed805 Mon Sep 17 00:00:00 2001 From: shum Date: Wed, 18 Feb 2026 14:37:59 +0000 Subject: [PATCH] implement FACK protocol command and ackXFTPChunk --- xftp-web/src/client.ts | 9 ++++++++- xftp-web/src/protocol/commands.ts | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/xftp-web/src/client.ts b/xftp-web/src/client.ts index 1384147fb..3d1f823e5 100644 --- a/xftp-web/src/client.ts +++ b/xftp-web/src/client.ts @@ -16,7 +16,7 @@ import { import {verifyIdentityProof} from "./crypto/identity.js" import {generateX25519KeyPair, encodePubKeyX25519, dh} from "./crypto/keys.js" import { - encodeFNEW, encodeFADD, encodeFPUT, encodeFGET, encodeFDEL, encodePING, + encodeFNEW, encodeFADD, encodeFPUT, encodeFGET, encodeFACK, encodeFDEL, encodePING, decodeResponse, type FileResponse, type FileInfo, type XFTPErrorType } from "./protocol/commands.js" import {decryptReceivedChunk} from "./download.js" @@ -430,6 +430,13 @@ export async function deleteXFTPChunk( if (response.type !== "FROk") throw new Error("unexpected response: " + response.type) } +export async function ackXFTPChunk( + agent: XFTPClientAgent, server: XFTPServer, rpKey: Uint8Array, rId: Uint8Array +): Promise { + const {response} = await sendXFTPCommand(agent, server, rpKey, rId, encodeFACK()) + if (response.type !== "FROk") throw new Error("unexpected response: " + response.type) +} + export async function pingXFTP(agent: XFTPClientAgent, server: XFTPServer): Promise { const client = await getXFTPServerClient(agent, server) const corrId = new Uint8Array(0) diff --git a/xftp-web/src/protocol/commands.ts b/xftp-web/src/protocol/commands.ts index 3ca43541f..ede1fbde1 100644 --- a/xftp-web/src/protocol/commands.ts +++ b/xftp-web/src/protocol/commands.ts @@ -73,6 +73,8 @@ export function encodeFPUT(): Uint8Array { return ascii("FPUT") } export function encodeFDEL(): Uint8Array { return ascii("FDEL") } +export function encodeFACK(): Uint8Array { return ascii("FACK") } + export function encodeFGET(rcvDhKey: Uint8Array): Uint8Array { return concatBytes(ascii("FGET"), SPACE, encodeBytes(rcvDhKey)) }