Skip to content

About

Open Relativity Short Message Format (.rsmf) files in Node or the browser, with no dependencies: manifest, attachments, and a report of facts. CLI included.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

rsmf-reader

Open a Relativity Short Message Format (.rsmf) file and see what is in it: the manifest, the attachments, and a report of what the file says about itself. No dependencies, and the same code runs in Node and in a browser tab.

RSMF is the format eDiscovery platforms take chat and text messages in: an RFC 5322 message whose base64 part is a ZIP holding rsmf_manifest.json and the attachments. If somebody has sent you one and you have no platform to load it into, or you are generating them and want to check the output before an import fails an hour in, this is for you.

It is the library behind the browser viewer at getchatexport.com/tools/rsmf-viewer, published on its own.

Command line

npx rsmf-reader conversation.rsmf
chatexport-sample.rsmf

Envelope                  MIME message
X-RSMF-Version            2.0.0
X-RSMF-Generator          ChatExport 0.5.1
X-RSMF-EventCount         31
Subject                   James Whitmore
Manifest version          2.0.0
Participants              2
Conversations             1
Events                    31
  messages                31
  disclaimers             0
Attachments named         3
Attachments present       3
ZIP entries               4 (4 stored, 0 deflated)

Nothing to report: every named attachment is present and every reference is declared.

Facts about the file, not a validation. Relativity publishes its own validator.
Option What it does
--json The same report as JSON on stdout, for scripts
--extract <dir> Also writes rsmf_manifest.json and every attachment the manifest names into <dir>. An attachment id that would land outside <dir> (../x) is skipped and listed

Exit codes: 0 the file opened, whatever the report says; 1 it could not be opened, and the message says why; 2 the command line was wrong. Missing attachments do not change the exit code on purpose. The report is a statement of facts, and which facts should fail your pipeline is your decision:

npx rsmf-reader file.rsmf --json | jq -e '.report.attachments.missing == []'

Library

npm install rsmf-reader
import { readFile } from 'node:fs/promises'
import { openRsmf, readAttachment } from 'rsmf-reader'

const result = await openRsmf(new Uint8Array(await readFile('conversation.rsmf')))

if ('problem' in result) {
  console.log(result.problem) // e.g. { kind: 'no-manifest' }
} else {
  const { manifest, report } = result
  console.log(report.counts.events, report.attachments.missing)

  const first = manifest.events.find((e) => e.attachments?.length)
  const bytes = await readAttachment(result, first.attachments[0].id)
}

In a browser, pass the bytes of a dropped file:

const result = await openRsmf(new Uint8Array(await file.arrayBuffer()))

openRsmf accepts either a full .rsmf message or a bare rsmf.zip. It decodes the base64 part and reads the archive's directory; it does not inflate any attachment until you ask for that one with readAttachment, so a file full of video costs one pass over the base64 and the manifest, nothing more.

What can stop a file from opening

result.problem.kind is one of:

Kind Meaning
not-rsmf Neither a MIME message with a boundary nor a ZIP archive
no-archive-part A MIME message, but no base64 part that could be rsmf.zip
zip-unreadable The archive could not be read; detail is truncated, zip64 or no-eocd
no-manifest The archive has no rsmf_manifest.json (at the root or under one folder)
manifest-not-json The manifest is not valid JSON
manifest-shape The manifest lacks one of the three arrays the schema requires at the root; missing names them
deflate-unsupported The manifest is deflated and the runtime has no DecompressionStream

The first failure names the problem and nothing after it is attempted, because every later step would report the same root cause less usefully.

What the report says

Field
envelope Whether there was a MIME envelope, and its X-RSMF-Version, X-RSMF-Generator, X-RSMF-EventCount and Subject
manifestVersion The manifest's own version
counts Participants, conversations, events, and of the events how many are messages and disclaimers
eventCountMismatch X-RSMF-EventCount disagrees with the events in the manifest
overRecommended More than the 10,000 events per file Relativity recommends
attachments How many are named, how many are present, and the ids of the missing ones
undeclaredParticipants, undeclaredConversations Ids used by events and not declared at the root
badTimestamps Events whose timestamp does not parse, with a sample of their ids
unknownEventTypes Event types other than message and disclaimer
zip Entry counts by compression method, whether names are flagged UTF-8, and files no event names

What it is not

  • Not Relativity's validator. Nothing here says "valid". Whether a platform accepts a file is that platform's decision, and Relativity publishes its own validator for it. This reader states facts that are worth knowing first.
  • Not a writer. It reads RSMF; it does not create it.
  • No zip64. An archive past 4 GB or with more than 65,535 entries is reported as zip64 rather than misread.
  • Stored and deflate only. Encrypted entries and other compression methods are refused per entry, so the manifest still opens when one attachment is odd.

Tolerated on purpose, because real files do it: LF-only line endings, a missing X-RSMF-Version, the archive part under any name as long as it is base64, a manifest one folder deep, data descriptors and directory entries in the ZIP.

Development

npm install
npm test        # compiles src and test, then runs node --test on the output
npm run build   # dist/ for publishing

The tests run against the compiled JavaScript, the same files that are published. test/fixtures/chatexport-sample.rsmf is a real export of a fictional conversation, the same file offered as a sample on getchatexport.com.

Requires Node 18 or later for DecompressionStream and Response.

See also

Licence

MIT. See LICENSE.

About

Open Relativity Short Message Format (.rsmf) files in Node or the browser, with no dependencies: manifest, attachments, and a report of facts. CLI included.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages