{"action":"created","comment":{"url":"https://api.github.com/repos/keybase/node-saltpack/pulls/comments/76327150","id":76327150,"diff_hunk":"@@ -0,0 +1,114 @@\n+# This class prettifies the output of our armoring stream, according to the saltpack spec.\n+# At the moment, per the spec, it simply frames the message, and inserts a space every 15 characters\n+# and a newline every 200 words.\n+\n+stream = require('keybase-chunk-stream')\n+util = require('./util')\n+\n+# Punctuation - this is modular\n+space = new Buffer(' ')\n+newline = new Buffer('\\n')\n+punctuation = new Buffer('.')\n+\n+words_per_line = 200\n+chars_per_word = 15\n+\n+# For working with the chunk streams\n+noop = () ->\n+\n+# This stream takes basex'd input and writes framed output, as per https://saltpack.org/armoring#framing-the-basex-payload\n+exports.FormatStream = class FormatStream extends stream.ChunkStream\n+\n+  # _format is the transform function passed to the chunk stream constructor\n+  _format : (chunk) ->\n+    # this is only ever called during flush()\n+    if chunk.length < @block_size\n+      return chunk\n+\n+    # write out the header if we haven't already\n+    res = new Buffer('')\n+    unless @_header_written\n+      res = Buffer.concat([@_header, punctuation, space])\n+      @_header_written = true\n+\n+    @_word_count++\n+    if @_word_count isnt 200\n+      # res will be an empty buffer except when writing the header\n+      res = Buffer.concat([res, chunk, space])\n+    else\n+      # ditto\n+      res = Buffer.concat([res, chunk, newline])\n+    return res\n+\n+  _flush : (cb) ->\n+    super(noop)\n+    @push(Buffer.concat([punctuation, space, @_footer, punctuation]))\n+    cb()\n+\n+  constructor : ({brand}) ->\n+    if brand? then _brand = brand else _brand = 'KEYBASE'\n+    @_header = new Buffer(\"BEGIN#{space}#{_brand}#{space}SALTPACK#{space}ENCRYPTED#{space}MESSAGE\")\n+    @_footer = new Buffer(\"END#{space}#{_brand}#{space}SALTPACK#{space}ENCRYPTED#{space}MESSAGE\")\n+    @_header_written = false\n+    @_word_count = 0\n+    super({transform_func : @_format, block_size : 15, exact_chunking : true, writableObjectMode : false, readableObjectMode : false})\n+\n+exports.DeformatStream = class DeformatStream extends stream.ChunkStream\n+\n+  _header_mode = 0\n+  _body_mode = 1\n+  _footer_mode = 2\n+  _strip_re = /[>\\n\\r\\t ]/g\n+\n+  _strip = (chunk) -> chunk = new Buffer(chunk.toString().replace(_strip_re, \"\"))\n+\n+  _deformat : (chunk) ->\n+   switch @_mode\n+      # verify the header, and print out any body that we may have gotten with it\n+      when _header_mode\n+        index = chunk.indexOf(punctuation[0])\n+        if index > 0\n+          after_period = chunk[index+1...]\n+          header = Buffer.concat([@_partial, chunk[0...index]])\n+          # clear this buffer out to be reused by the footer\n+          @_partial = new Buffer('')\n+          re = /[>\\n\\r\\t ]*BEGIN[>\\n\\r\\t ]+([a-zA-Z0-9]+)?[>\\n\\r\\t ]+SALTPACK[>\\n\\r\\t ]+(ENCRYPTED[>\\n\\r\\t ]+MESSAGE)|(SIGNED[>\\n\\r\\t ]+MESSAGE)|(DETACHED[>\\n\\r\\t ]+SIGNATURE)[>\\n\\r\\t ]*/\n+          unless re.test(header) then throw new Error(\"Header failed to verify!\")\n+          @_header = _strip(header)\n+          @_mode = _body_mode\n+          return _strip(after_period)","path":"src/format.iced","position":79,"original_position":79,"commit_id":"1b9a4d253e974cc2ca514c8854343b9b27ff3c8b","original_commit_id":"1b9a4d253e974cc2ca514c8854343b9b27ff3c8b","user":{"login":"mpcsh","id":2894019,"avatar_url":"https://avatars.githubusercontent.com/u/2894019?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcsh","html_url":"https://github.com/mpcsh","followers_url":"https://api.github.com/users/mpcsh/followers","following_url":"https://api.github.com/users/mpcsh/following{/other_user}","gists_url":"https://api.github.com/users/mpcsh/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcsh/subscriptions","organizations_url":"https://api.github.com/users/mpcsh/orgs","repos_url":"https://api.github.com/users/mpcsh/repos","events_url":"https://api.github.com/users/mpcsh/events{/privacy}","received_events_url":"https://api.github.com/users/mpcsh/received_events","type":"User","site_admin":false},"body":"That's a really good point. Hm. Need to think this through","created_at":"2016-08-25T21:21:37Z","updated_at":"2016-08-25T21:21:37Z","html_url":"https://github.com/keybase/node-saltpack/pull/2#discussion_r76327150","pull_request_url":"https://api.github.com/repos/keybase/node-saltpack/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/comments/76327150"},"html":{"href":"https://github.com/keybase/node-saltpack/pull/2#discussion_r76327150"},"pull_request":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/keybase/node-saltpack/pulls/2","id":79374314,"html_url":"https://github.com/keybase/node-saltpack/pull/2","diff_url":"https://github.com/keybase/node-saltpack/pull/2.diff","patch_url":"https://github.com/keybase/node-saltpack/pull/2.patch","issue_url":"https://api.github.com/repos/keybase/node-saltpack/issues/2","number":2,"state":"open","locked":false,"title":"{server,browser}-side saltpack encryption/decryption","user":{"login":"mpcsh","id":2894019,"avatar_url":"https://avatars.githubusercontent.com/u/2894019?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcsh","html_url":"https://github.com/mpcsh","followers_url":"https://api.github.com/users/mpcsh/followers","following_url":"https://api.github.com/users/mpcsh/following{/other_user}","gists_url":"https://api.github.com/users/mpcsh/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcsh/subscriptions","organizations_url":"https://api.github.com/users/mpcsh/orgs","repos_url":"https://api.github.com/users/mpcsh/repos","events_url":"https://api.github.com/users/mpcsh/events{/privacy}","received_events_url":"https://api.github.com/users/mpcsh/received_events","type":"User","site_admin":false},"body":"Run `npm install` before any tests - use `make test` to run them, and `make coverage` to run with `istanbul`. If you like, you can encrypt to yourself in the `test/stream.iced` file by adding your public key (with the `0121` and `0a` frames stripped) found with `keybase dump-keyfamily [username]`.","created_at":"2016-07-29T15:04:52Z","updated_at":"2016-08-25T21:21:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fd246b053a63cd0a8bd1d1a9f7134e509495f4d","assignee":{"login":"oconnor663","id":860932,"avatar_url":"https://avatars.githubusercontent.com/u/860932?v=3","gravatar_id":"","url":"https://api.github.com/users/oconnor663","html_url":"https://github.com/oconnor663","followers_url":"https://api.github.com/users/oconnor663/followers","following_url":"https://api.github.com/users/oconnor663/following{/other_user}","gists_url":"https://api.github.com/users/oconnor663/gists{/gist_id}","starred_url":"https://api.github.com/users/oconnor663/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oconnor663/subscriptions","organizations_url":"https://api.github.com/users/oconnor663/orgs","repos_url":"https://api.github.com/users/oconnor663/repos","events_url":"https://api.github.com/users/oconnor663/events{/privacy}","received_events_url":"https://api.github.com/users/oconnor663/received_events","type":"User","site_admin":false},"assignees":[{"login":"oconnor663","id":860932,"avatar_url":"https://avatars.githubusercontent.com/u/860932?v=3","gravatar_id":"","url":"https://api.github.com/users/oconnor663","html_url":"https://github.com/oconnor663","followers_url":"https://api.github.com/users/oconnor663/followers","following_url":"https://api.github.com/users/oconnor663/following{/other_user}","gists_url":"https://api.github.com/users/oconnor663/gists{/gist_id}","starred_url":"https://api.github.com/users/oconnor663/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oconnor663/subscriptions","organizations_url":"https://api.github.com/users/oconnor663/orgs","repos_url":"https://api.github.com/users/oconnor663/repos","events_url":"https://api.github.com/users/oconnor663/events{/privacy}","received_events_url":"https://api.github.com/users/oconnor663/received_events","type":"User","site_admin":false},{"login":"maxtaco","id":866815,"avatar_url":"https://avatars.githubusercontent.com/u/866815?v=3","gravatar_id":"","url":"https://api.github.com/users/maxtaco","html_url":"https://github.com/maxtaco","followers_url":"https://api.github.com/users/maxtaco/followers","following_url":"https://api.github.com/users/maxtaco/following{/other_user}","gists_url":"https://api.github.com/users/maxtaco/gists{/gist_id}","starred_url":"https://api.github.com/users/maxtaco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxtaco/subscriptions","organizations_url":"https://api.github.com/users/maxtaco/orgs","repos_url":"https://api.github.com/users/maxtaco/repos","events_url":"https://api.github.com/users/maxtaco/events{/privacy}","received_events_url":"https://api.github.com/users/maxtaco/received_events","type":"User","site_admin":false},{"login":"mpcsh","id":2894019,"avatar_url":"https://avatars.githubusercontent.com/u/2894019?v=3","gravatar_id":"","url":"https://api.github.com/users/mpcsh","html_url":"https://github.com/mpcsh","followers_url":"https://api.github.com/users/mpcsh/followers","following_url":"https://api.github.com/users/mpcsh/following{/other_user}","gists_url":"https://api.github.com/users/mpcsh/gists{/gist_id}","starred_url":"https://api.github.com/users/mpcsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpcsh/subscriptions","organizations_url":"https://api.github.com/users/mpcsh/orgs","repos_url":"https://api.github.com/users/mpcsh/repos","events_url":"https://api.github.com/users/mpcsh/events{/privacy}","received_events_url":"https://api.github.com/users/mpcsh/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/keybase/node-saltpack/pulls/2/commits","review_comments_url":"https://api.github.com/repos/keybase/node-saltpack/pulls/2/comments","review_comment_url":"https://api.github.com/repos/keybase/node-saltpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keybase/node-saltpack/issues/2/comments","statuses_url":"https://api.github.com/repos/keybase/node-saltpack/statuses/1b9a4d253e974cc2ca514c8854343b9b27ff3c8b","head":{"label":"keybase:mark/CORE-3369","ref":"mark/CORE-3369","sha":"1b9a4d253e974cc2ca514c8854343b9b27ff3c8b","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":49149283,"name":"node-saltpack","full_name":"keybase/node-saltpack","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/node-saltpack","description":"our standard saltpack implementation in JS","fork":false,"url":"https://api.github.com/repos/keybase/node-saltpack","forks_url":"https://api.github.com/repos/keybase/node-saltpack/forks","keys_url":"https://api.github.com/repos/keybase/node-saltpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/node-saltpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/node-saltpack/teams","hooks_url":"https://api.github.com/repos/keybase/node-saltpack/hooks","issue_events_url":"https://api.github.com/repos/keybase/node-saltpack/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/node-saltpack/events","assignees_url":"https://api.github.com/repos/keybase/node-saltpack/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/node-saltpack/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/node-saltpack/tags","blobs_url":"https://api.github.com/repos/keybase/node-saltpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/node-saltpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/node-saltpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/node-saltpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/node-saltpack/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/node-saltpack/languages","stargazers_url":"https://api.github.com/repos/keybase/node-saltpack/stargazers","contributors_url":"https://api.github.com/repos/keybase/node-saltpack/contributors","subscribers_url":"https://api.github.com/repos/keybase/node-saltpack/subscribers","subscription_url":"https://api.github.com/repos/keybase/node-saltpack/subscription","commits_url":"https://api.github.com/repos/keybase/node-saltpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/node-saltpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/node-saltpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/node-saltpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/node-saltpack/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/node-saltpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/node-saltpack/merges","archive_url":"https://api.github.com/repos/keybase/node-saltpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/node-saltpack/downloads","issues_url":"https://api.github.com/repos/keybase/node-saltpack/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/node-saltpack/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/node-saltpack/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/node-saltpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/node-saltpack/labels{/name}","releases_url":"https://api.github.com/repos/keybase/node-saltpack/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/node-saltpack/deployments","created_at":"2016-01-06T17:08:21Z","updated_at":"2016-07-15T02:35:26Z","pushed_at":"2016-08-24T21:05:17Z","git_url":"git://github.com/keybase/node-saltpack.git","ssh_url":"git@github.com:keybase/node-saltpack.git","clone_url":"https://github.com/keybase/node-saltpack.git","svn_url":"https://github.com/keybase/node-saltpack","homepage":null,"size":715,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"keybase:master","ref":"master","sha":"589e3473d94e95966e6c01df0198cba4d80e3003","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":49149283,"name":"node-saltpack","full_name":"keybase/node-saltpack","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/node-saltpack","description":"our standard saltpack implementation in JS","fork":false,"url":"https://api.github.com/repos/keybase/node-saltpack","forks_url":"https://api.github.com/repos/keybase/node-saltpack/forks","keys_url":"https://api.github.com/repos/keybase/node-saltpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/node-saltpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/node-saltpack/teams","hooks_url":"https://api.github.com/repos/keybase/node-saltpack/hooks","issue_events_url":"https://api.github.com/repos/keybase/node-saltpack/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/node-saltpack/events","assignees_url":"https://api.github.com/repos/keybase/node-saltpack/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/node-saltpack/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/node-saltpack/tags","blobs_url":"https://api.github.com/repos/keybase/node-saltpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/node-saltpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/node-saltpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/node-saltpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/node-saltpack/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/node-saltpack/languages","stargazers_url":"https://api.github.com/repos/keybase/node-saltpack/stargazers","contributors_url":"https://api.github.com/repos/keybase/node-saltpack/contributors","subscribers_url":"https://api.github.com/repos/keybase/node-saltpack/subscribers","subscription_url":"https://api.github.com/repos/keybase/node-saltpack/subscription","commits_url":"https://api.github.com/repos/keybase/node-saltpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/node-saltpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/node-saltpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/node-saltpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/node-saltpack/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/node-saltpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/node-saltpack/merges","archive_url":"https://api.github.com/repos/keybase/node-saltpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/node-saltpack/downloads","issues_url":"https://api.github.com/repos/keybase/node-saltpack/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/node-saltpack/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/node-saltpack/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/node-saltpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/node-saltpack/labels{/name}","releases_url":"https://api.github.com/repos/keybase/node-saltpack/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/node-saltpack/deployments","created_at":"2016-01-06T17:08:21Z","updated_at":"2016-07-15T02:35:26Z","pushed_at":"2016-08-24T21:05:17Z","git_url":"git://github.com/keybase/node-saltpack.git","ssh_url":"git@github.com:keybase/node-saltpack.git","clone_url":"https://github.com/keybase/node-saltpack.git","svn_url":"https://github.com/keybase/node-saltpack","homepage":null,"size":715,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/2"},"html":{"href":"https://github.com/keybase/node-saltpack/pull/2"},"issue":{"href":"https://api.github.com/repos/keybase/node-saltpack/issues/2"},"comments":{"href":"https://api.github.com/repos/keybase/node-saltpack/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keybase/node-saltpack/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/keybase/node-saltpack/statuses/1b9a4d253e974cc2ca514c8854343b9b27ff3c8b"}}}}
{"actor":{"display_login":"mpcsh"}}