Add file hash support to NIP-94 mirrors

This commit is contained in:
thePR0M3TH3AN committed 2025-10-30 12:41:49 -04:00
1 parent 36bcbae0e9
commit 6eb8594e28
3 files changed
+231 -30

No files matched your search

+32
View File
@@ -107,3 +107,35 @@ test("mirrorVideoEvent lowercases inferred MIME types", async () => {
assert.ok(mTag, "mirror events must include a MIME tag");
assert.equal(mTag[1], "video/webm");
});
test("mirrorVideoEvent includes hash tags when provided", async () => {
const eventId = "hash-tags";
const actorPubkey = "3".repeat(64);
const { client } = createPublishClient({ actorPubkey });
const fileHash = "a".repeat(64);
const originalHash = "b".repeat(64);
const result = await mirrorVideoEvent({
client,
eventId,
options: {
url: "https://videos.example/demo.mp4",
fileSha256: fileHash.toUpperCase(),
originalFileSha256: originalHash,
},
resolveActiveSigner: resolveActiveSignerStub,
shouldRequestExtensionPermissions: shouldRequestExtensionPermissionsStub,
signEventWithPrivateKey: signEventWithPrivateKeyStub,
inferMimeTypeFromUrl: () => "video/mp4",
});
assert.equal(result.ok, true);
const xTag = result.event?.tags?.find(
(tag) => Array.isArray(tag) && tag[0] === "x",
);
const oxTag = result.event?.tags?.find(
(tag) => Array.isArray(tag) && tag[0] === "ox",
);
assert.deepEqual(xTag, ["x", fileHash]);
assert.deepEqual(oxTag, ["ox", originalHash]);
});