Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ephemeral returns #44

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
4f73657
generate an eph key and include it in requests
ameba23 Jan 8, 2019
b6c736d
encrypt returned shards
ameba23 Jan 10, 2019
69fced9
temporarily disable validating shards, and encrypted ones wont pass
ameba23 Jan 10, 2019
74653ae
reply test
ameba23 Jan 10, 2019
1336ef2
recombinetest
ameba23 Jan 10, 2019
8728bf3
use sbot plugin for tests
ameba23 Jan 14, 2019
95e3cdc
use plugin, begin decryption in recover.async.mend (not yet working)
ameba23 Jan 14, 2019
caa56c3
mend takes server
ameba23 Jan 14, 2019
32c9cdb
stringify dbKey
ameba23 Jan 24, 2019
5c85d7f
fix bug and improve method
ameba23 Jan 24, 2019
90fd9a9
pass server to v1 forward test
ameba23 Jan 25, 2019
4c2ead0
pass server to v2 forward test
ameba23 Jan 25, 2019
0855974
pass server to v1 request test
ameba23 Jan 25, 2019
3bd7f31
pass server to v2 request test
ameba23 Jan 25, 2019
07ad245
include ephemeral keys generation and encryption in fetch/mend v2 test
ameba23 Jan 25, 2019
fdb4f30
omit ephemeral key decryption from v1 shards
ameba23 Jan 25, 2019
f2a8f22
isReply checks for boxed message
ameba23 Jan 25, 2019
8403608
add generateAndStore to additional v2 reply test
ameba23 Jan 25, 2019
3b91518
remove debug logging
ameba23 Jan 25, 2019
24833a2
lint
ameba23 Jan 25, 2019
8a127b9
use regex for testing .box suffix
ameba23 Jan 25, 2019
653e27d
method for deleting an ephemeral keypair
ameba23 Jan 27, 2019
d8d2c09
test for method for deleting an ephemeral keypair
ameba23 Jan 27, 2019
2e8f7ac
readme
ameba23 Jan 27, 2019
37dab83
improve recover.pull.replies
ameba23 Jan 28, 2019
92ba441
method to delete all ephemeral keypairs associated with a given rootid
ameba23 Jan 28, 2019
f1c7dd4
include deleteKeyPairs method in readme
ameba23 Jan 31, 2019
f052e61
expose deleteKeyPairs method
ameba23 Jan 31, 2019
6c75134
improve contextMessage in recover.async.mend
ameba23 Jan 31, 2019
17334fe
improve contextMessage in recover.async.reply
ameba23 Jan 31, 2019
a6b2d21
update contextMessage in tests
ameba23 Jan 31, 2019
f9c6ff0
remove additional logging
ameba23 Feb 2, 2019
b3961b9
handle non-boxed shards
ameba23 Feb 2, 2019
717c293
Merge pull request #49 from blockades/improve_ephemeral_returns
ameba23 Feb 4, 2019
fae55cb
remove fn from mend
ameba23 Feb 5, 2019
30249e8
merge conflict
ameba23 Feb 5, 2019
3bb58da
comments, additional test for deleteKeyPairs
ameba23 Feb 5, 2019
a2cf5ee
update testbot for renamed module
ameba23 Feb 6, 2019
ee1e357
update PLUGIN_DEPS for ephemeral keys plugin
ameba23 Feb 6, 2019
a326b31
add ssb-ephemeral-keys as a dev dependency
ameba23 Feb 6, 2019
4c93341
deleteKeyPair returns true if successful
ameba23 Feb 8, 2019
dae6624
tidy comments
ameba23 Mar 14, 2019
1f22c81
change to using async boxmessage
ameba23 Mar 15, 2019
ba838dd
remove stringify from dbkeys as it is done in the plugin
ameba23 Mar 15, 2019
26ba6bd
rename isBoxedMessage
ameba23 Mar 15, 2019
86d0b21
rename deleteEphemeralKeypairs
ameba23 Mar 15, 2019
e3ab3ab
rename variable in test
ameba23 Mar 15, 2019
98d17ed
rename tests, fix test for async boxMessage
ameba23 Mar 15, 2019
4af79ed
rename deleteEphemeralKeypairs
ameba23 Mar 15, 2019
f702f77
more renaming
ameba23 Mar 15, 2019
e3a68f8
yet more renaming
ameba23 Mar 15, 2019
634771e
update readme
ameba23 Mar 15, 2019
60ff58d
fix test for async boxmessage
ameba23 Mar 15, 2019
81fbb4a
fix fetch test for async boxmessage
ameba23 Mar 15, 2019
a770eac
fix boxMessage in reply.js
ameba23 Mar 15, 2019
0c9cf96
change variable name
ameba23 Mar 15, 2019
e61efc6
fixed request v2 test to work with async box method
ameba23 Mar 21, 2019
a1fe05b
bump ssb-ephemeral-keys
ameba23 Mar 21, 2019
af46260
fix merge conflicts
ameba23 Mar 21, 2019
035bd98
modify test for deleting a single ephemeral keypair for obligatory co…
ameba23 Jun 15, 2019
7ee8c37
modify test for deleting all ephemeral keypairs for obligatory contex…
ameba23 Jun 15, 2019
d6883ad
likewise for unboxing
ameba23 Jun 15, 2019
dc90ec9
bump ssb-ephemeral-keys
ameba23 Jun 24, 2019
acff648
Merge pull request #57 from blockades/ephemeral_returns_updated
ameba23 Jun 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ This will attempt to recombine the decrypted shards included in reply messages a

This also works for forwarded shards, you just need to provide the root from on of the fwds.

#### `darkCrystal.recover.async.deleteEphemeralKeyPairs(rootId, callback)`

Deletes the ephemeral keypairs for all returned shards associated with the given rootId (effectively deleting the shards). If successful, no errors will be returned in the callback.

### Root methods

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const inject = require('scuttle-inject')

const raw = require('./methods')
const PLUGIN_DEPS = ['private', 'query', 'backlinks']
const PLUGIN_DEPS = ['private', 'query', 'backlinks', 'ephemeral']

const niceMappings = {}

Expand Down
14 changes: 13 additions & 1 deletion isReply.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { isReply: _isReply } = require('ssb-dark-crystal-schema')
const getContent = require('ssb-msg-content')
const isString = require('./lib/isString')
const { validateShard } = require('dark-crystal-secrets')

module.exports = function isReply (msg) {
Expand All @@ -11,10 +12,21 @@ module.exports = function isReply (msg) {
const errors = []

if (!_isReply(msg)) errors.push(new Error('invalid reply'))
if (!validateShard(shard, shareVersion)) errors.push(new Error('invalid shard'))
if (!isString(shard)) {
errors.push(new Error('body must contain a string'))
} else {
if (!isBoxedShare(shard) || shareVersion === '1.0.0') {
if (!validateShard(shard, shareVersion)) errors.push(new Error('invalid shard'))
}
}

if (!errors.length) return true

isReply.errors = errors
return false
}

// TODO: should we use isCanonicalBase64 ?
function isBoxedShare (message) {
return /\.box$/.test(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for the moment, but we should be able to prove this is a boxed message using a better means. checking if there's .box at the end isn't reliable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few people recently have reported problems with isCanaonicalBase64 recently which is why i hesistated to use it. there is a regex for encrypted messages in ssb-schema-definitions but @mixmix trimmed it to only check for the .box suffix after having problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommend rename this isBoxedShard to remove confusion about this being the content of a message being boxed... ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or rather isBoxedShare because the shard is a shard message, and a share is the piece which is actually being looked at, then it's in line with shareVersion and makes more sense overall I think

}
3 changes: 2 additions & 1 deletion methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = {
async: {
recombine: require('./recover/async/recombine'),
reply: require('./recover/async/reply'),
request: require('./recover/async/request')
request: require('./recover/async/request'),
deleteEphemeralKeyPairs: require('./recover/async/deleteEphemeralKeyPairs')
},
pull: {
requests: require('./recover/pull/requests'),
Expand Down
211 changes: 211 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"devDependencies": {
"scuttle-testbot": "^1.1.6",
"ssb-backlinks": "^0.7.3",
"ssb-ephemeral-keys": "^1.0.2",
"ssb-private": "^0.2.3",
"ssb-query": "^2.3.0",
"standard": "^12.0.1",
Expand Down
13 changes: 13 additions & 0 deletions recover/async/deleteEphemeralKeyPair.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { isMsgId, isFeed } = require('ssb-ref')

module.exports = function (server) {
return function deleteEphemeralKeyPair (rootId, recipient, callback) {
if (!isMsgId(rootId)) return callback(new Error('Invalid root'))
if (!isFeed(recipient)) return callback(new Error('Invalid recipient'))

server.ephemeral.deleteKeyPair({ rootId, recp: recipient }, (err) => {
if (err) return callback(err)
callback(null, true)
})
}
}
23 changes: 23 additions & 0 deletions recover/async/deleteEphemeralKeyPairs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { isMsgId } = require('ssb-ref')
const GetReplies = require('../pull/replies')
const pull = require('pull-stream')
const DeleteEphemeralKeyPair = require('./deleteEphemeralKeyPair')

module.exports = function (server) {
const deleteEphemeralKeyPair = DeleteEphemeralKeyPair(server)
const getReplies = GetReplies(server)
return function deleteEphemeralKeyPairs (rootId, callback) {
if (!isMsgId(rootId)) return callback(new Error('Invalid root'))
pull(
getReplies(rootId, { live: false }),
// pull.filter body contains boxed msg?
pull.asyncMap((reply, cb) => {
deleteEphemeralKeyPair(rootId, reply.value.author, (err) => {
if (err) cb(err)
cb(null, reply)
})
}),
pull.collect(callback)
)
}
}
Loading