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 41 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.deleteKeyPairs(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,6 +1,7 @@
const { isReply: _isReply } = require('ssb-dark-crystal-schema')
const getContent = require('ssb-msg-content')
const { validateShard } = require('./lib/secrets-wrapper')
const isString = require('./lib/isString')

module.exports = function isReply (msg) {
const {
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 (!isBoxedMessage(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 isBoxedMessage (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'),
deleteKeyPairs: require('./recover/async/deleteKeyPairs')
},
pull: {
requests: require('./recover/pull/requests'),
Expand Down
Loading