diff --git a/group/add-member/README.md b/group/add-member/README.md index ecb65de..34d1a9f 100644 --- a/group/add-member/README.md +++ b/group/add-member/README.md @@ -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 @@ -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 diff --git a/group/add-member/v2/schema.js b/group/add-member/v2/schema.js index 8c5533f..361f933 100644 --- a/group/add-member/v2/schema.js +++ b/group/add-member/v2/schema.js @@ -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' }, diff --git a/group/add-member/v2/schema.json b/group/add-member/v2/schema.json index e5dca17..93cdbc6 100644 --- a/group/add-member/v2/schema.json +++ b/group/add-member/v2/schema.json @@ -22,6 +22,15 @@ "secret": { "$ref": "#/definitions/secret" }, + "oldSecrets": { + "type": "array", + "items": [ + { + "$ref": "#/definitions/secret" + } + ], + "minItems": 0 + }, "root": { "$ref": "#/definitions/messageId" }, diff --git a/test/add-member.test.js b/test/add-member.test.js index 6cb3346..f140b0f 100644 --- a/test/add-member.test.js +++ b/test/add-member.test.js @@ -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 @@ -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() })