Fingerprint a file
fingerprint() in the SDKs: the fingerprint of a file, a buffer, or a stream, made where the bytes live. PacSpace receives the fingerprint and the size, never the file.
Every entry carries at least one fingerprint: the fingerprint of the file, the payload, or the object the entry is about. You make it where the bytes are, with the SDK's fingerprint helper, and the result goes in payloads. PacSpace receives the fingerprint and the size. It never receives the file, its name, or its location.
Call
import { openAsBlob } from 'node:fs';
import { Readable } from 'node:stream';
import { fingerprint } from '@pacspace-io/sdk';
// A file on disk.
const ref = await fingerprint(await openAsBlob('./build-2026-09-15.tar'));
// Something you already hold in memory, such as a database row serialized the way you store it.
const refFromBuffer = await fingerprint(buffer); // Buffer, Uint8Array, or ArrayBuffer
// A stream, for example an object body read from your own storage. The object never leaves the bucket.
const refFromStream = await fingerprint(Readable.toWeb(objectBody));
// In a browser, the File the person chose.
const refFromFile = await fingerprint(input.files[0]);What comes back
{ "alg": "sha-256", "digest": "731620161155f68e1209f22bc34a726bf5a583f40acf23ae55684b674fdbebf2", "byteLength": "100000" }alg is the method, always sha-256. digest is the fingerprint, 64 hex characters. byteLength is the size in bytes, as a string. The three together are what an entry carries for one file, and what the check compares your copy against later: if you hold the file, fingerprint it again and hand the result to records.check as expect.
What to fingerprint
Fingerprint the thing as you store it, so you can reproduce the fingerprint later from what you hold. A file as written to disk. A database row serialized the way you keep it. A message body as sent. If you serialize the same data two different ways, you get two different fingerprints; pick one form and keep it.
An entry can carry more than one fingerprint. A coding agent's entry might carry the diff and the summary; a release entry might carry the artifact and its settings file.
Inputs
TypeScript accepts a File, a Blob, an ArrayBuffer, a Uint8Array, a ReadableStream, or any iterable of byte chunks, and reads in chunks so a large file is never held whole. Node 20 or later, or a browser. Python accepts bytes, a file object opened in binary mode, or any iterable of bytes.
When it refuses
| Code | The rule |
|---|---|
RECORD_PAYLOAD_ALG_UNSUPPORTED | A fingerprint is made with sha-256. |
RECORD_CONTENT_INVALID | The input is bytes, a file, a stream, or an iterable of bytes. |