Skip to content

Commit

Permalink
Merge pull request #33 from ssbc/old-secrets
Browse files Browse the repository at this point in the history
Add oldSecrets field to add-member
  • Loading branch information
Powersource authored May 9, 2023
2 parents d1058a8 + f4d3f27 commit e73f784
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 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. Should be undefined or at least empty 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
5 changes: 5 additions & 0 deletions group/add-member/v2/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = {
pattern: '^v2$'
},
secret: { $ref: '#/definitions/secret' },
oldSecrets: {
type: 'array',
items: [{ $ref: '#/definitions/secret' }],
minItems: 0
},
root: { $ref: '#/definitions/messageId' },
creator: { $ref: '#/definitions/feedId' },
text: { type: 'string' },
Expand Down
9 changes: 9 additions & 0 deletions group/add-member/v2/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
"secret": {
"$ref": "#/definitions/secret"
},
"oldSecrets": {
"type": "array",
"items": [
{
"$ref": "#/definitions/secret"
}
],
"minItems": 0
},
"root": {
"$ref": "#/definitions/messageId"
},
Expand Down
9 changes: 9 additions & 0 deletions test/add-member.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Mock = (overwrite = {}) => {
type: 'group/add-member',
version: 'v2',
secret: Secret(),
oldSecrets: [Secret(), Secret()],
root: groupRoot,
creator: FeedId(),
text: 'welcome keks!', // optional
Expand Down Expand Up @@ -95,5 +96,13 @@ test('is-group-add-member', (t) => {
'%shGMltJNglMNLpxdnDGz/Y+j6HukBelnCS84D+GR2DM=.sha256'
t.false(isValid(sigilLink), 'fails if a link is a sigil link and not a uri')

const noOld = Mock()
noOld.oldSecrets = undefined
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.end()
})

0 comments on commit e73f784

Please sign in to comment.