New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

forever-chat-format

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forever-chat-format

Validators for a chat exporter to ensure data conforms to forever chat format standards

latest
npmnpm
Version
1.2.1
Version published
Weekly downloads
3
-25%
Maintainers
1
Weekly downloads
 
Created
Source

Forever Chat Format

Why

Because in the world where our communication is siloed into Google Hangouts, Facebook, iMessage, WhatsApp, etc etc it's getting hard to hold onto conversations for archival purposes. First thing we need is a universal format that we can export those proprietary chats into that's easy to understand, and that can be relied upon.

Basic Format

Output should be an array of hashes, and each object in the array is a JSON object defined as follows:

Chat Object Definition

NameTypeDescription
shastringsha1 of [sender, receiver, date, text, service]
senderstringThe handle of the person sending the message
receiverstringThe handle of the person receiving the message
is_from_mebooleantrue if you sent the message
send_errorbooleantrue if the message didn't send
dateISO-8601 datetimedate message was sent/received by sender
servicestringService message was sent using. All lowercase, dasherized. 'imessage', 'google-hangouts', 'facebook-messenger', 'sms'
date_readISO-8601 datetime(optional) date message was sent/read by receiver
date_deliveredISO-8601 datetime(optional) date message was delivered by receiver
participantsarray(see definition below) An array of strings of handles involved in the conversations. Used for grouping. For a two person conversation, this has two entries in it. Sender and receiver are always here.
message_textstringtext representation of the message
message_segmentsarray(see definition below) ordered segments of content as it appears in the message
attachmentsarray(see definition below) array of attachments
associated_shastringsha of message this message is in response to. Generally used for reactions
_debugobject(optional) debug information to help trace back to the source of the data

Message Segment Definition

NameTypePossible ValuesDescription
typestringtext, link, filebase segment type
file_typestringnull, or a mime_typeonly valid when type == file
pathstringurl or file path
textstringthe rendered name of the link, or the text content for the text, or optionally
Text Segment
{"type": "text", "text": "Why hello there"}
{"type": "link", "text": "Whoa, unreal", "path": "http://latlmes.com/technology/why-we-need-a-new-chat-format-1"}
File Segment
{"type": "file", "file_type": "image/png", "path": "/path/to/image.png"}
Reaction Segment
{"type": "reaction", "reaction_type": "laughed"}
Attachments

Array of attachments in the order they were received. Each attachment has the following properties. This information should also be made available in message_segments.

NameType
pathstring
typestring
Usage

The included tests check whether some json is valid forever chat format.

var foreverJson    = importer("test.json"); // done by an exporter

var {validate, runTests} = require('forever-chat-format-tests');

runTests(foreverJson); // runs mocha tests on data

The last step of your exporter should be to pass your exported data to the prepare function. It will check that the data conforms to the forever-chat-format spec and then return a hash with two keys: messages, and validations. Messages is all the data your exporter returned, and validations are what you see below:


"validations": {
  "version":           1.2 // forever chat version
  "checkedCount":      100 // number of records checked
  "errorCount":        0   // number of records with errors
  "recordsWithErrors":
  "ruleResults": { /* each rule keyed by name with errorCount and "erroredRecords" */
    "unique-sha": {
      "description":    "Each record should have a unique sha",
      "errorCount":     0,
      "erroredRecords": []
    }

    ...
  }
}
Testing
var foreverJson   = importer("test.json"); // done by an exporter
var {validate, runTests} = require('forever-chat-format-tests');
runTests(foreverJson);

FAQs

Package last updated on 18 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts