Skip to content

Commit

Permalink
Update readme for oldSecrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Powersource committed May 5, 2023
1 parent b5c4814 commit dee5074
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
12 changes: 10 additions & 2 deletions group/add-member/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

:warning: schema.json is generated so don't modify it directly

This is about adding people to your group
This is about adding people to your group, or



```js
var content = {
type: "group/add-member",
version: "v2",
secret: "3YUat1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
oldSecrets: [
"apple1ylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc=",
"potatoylIUVGaCjotAvof09DhyFxE8iGbF6QxLlCWWc="
],
root: "ssb:message/classic/THxjTGPuXvvxnbnAV7xVuVXdhDcmoNtDDN0j3UTxcd8=",
creator: "ssb:feed/bendybutt-v1/VuVXdhDTHxjTGPuXvvxnbnAV7xcmoNtDDN0j3UTxcd8=",
text: "welcome keks!", // optional
Expand Down Expand Up @@ -37,7 +43,9 @@ var content = {

Notes:

- `secret` is the symmetric key for the group
- `secret` is the symmetric key for this epoch
- `oldSecrets` is an array of all secrets of all predecessor epochs to this epoch, all the way back to the root epoch. Only there when initially adding someone to a group, it should be undefined on re-additions.
- when initially adding someone to a group, there should be one add-member message per tip epoch. this is to make it clear to the people in that epoch what the members of that epoch are. this is also why `oldSecrets` only should contain secrets of predecessor epochs, not of parallel fork epochs
- `root` is the same as `tangles.group.root`
- the redundancy is here to make it more obvious which root you should be using the compute `group_id`
- in the future our tangles may be _cloaked_ which means this key would become more important
Expand Down
3 changes: 1 addition & 2 deletions group/add-member/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
'type',
'version',
'secret',
'oldSecrets',
'root',
'creator',
'recps',
Expand All @@ -36,7 +35,7 @@ module.exports = {
oldSecrets: {
type: 'array',
items: [{ $ref: '#/definitions/secret' }],
minItems: 0
minItems: 1
},
root: { $ref: '#/definitions/messageId' },
creator: { $ref: '#/definitions/feedId' },
Expand Down
3 changes: 1 addition & 2 deletions group/add-member/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"type",
"version",
"secret",
"oldSecrets",
"root",
"creator",
"recps",
Expand All @@ -30,7 +29,7 @@
"$ref": "#/definitions/secret"
}
],
"minItems": 0
"minItems": 1
},
"root": {
"$ref": "#/definitions/messageId"
Expand Down
4 changes: 2 additions & 2 deletions test/add-member.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ test('is-group-add-member', (t) => {

const noOld = Mock()
noOld.oldSecrets = undefined
t.false(isValid(noOld), 'fails on missing oldSecrets')
t.true(isValid(noOld), 'can have missing oldSecrets (e.g. on re-additions)')

const emptyOld = Mock()
emptyOld.oldSecrets = []
t.true(isValid(emptyOld), 'allows empty oldSecrets')
t.false(isValid(emptyOld), 'disallows empty oldSecrets')

t.end()
})

0 comments on commit dee5074

Please sign in to comment.