[Feature] Add read only invites#20
Conversation
| const existing = await this.base.view.findOne('@autopass/invite', {}) | ||
| if (existing) { | ||
| if (this.member) await this.member.flushed() | ||
| return z32.encode(existing.invite) |
There was a problem hiding this comment.
we should check the existing invite to distinguish readonly and normal invite
There was a problem hiding this comment.
bug case
- create a normal invite
- create a normal invite => return existing => CORRECT
- create a readonly invite => return existing => INCORRECT because the existing is normal invite
There was a problem hiding this comment.
Thanks for flagging, makes sense since invites are deleted only once they are used, let me fix this so the flow is correct.
|
|
||
| await this.pass.deleteInvite() | ||
| } | ||
| const readOnly = JSON.parse(result.data.toString()).readOnly |
There was a problem hiding this comment.
curios question,
in the confirm side, we set an object of { key, encryptionKey, additional }
where is the result.data coming from?
There was a problem hiding this comment.
it comes from additional field
| key: this.base.key, | ||
| encryptionKey: this.base.encryptionKey | ||
| encryptionKey: this.base.encryptionKey, | ||
| additional: inv.additional |
There was a problem hiding this comment.
curios question, why do we need to send this additional back to the other side?
don't see they use it in the other side
only see
result.key
result.encryptionKey
and result.data?
There was a problem hiding this comment.
result.data comes from additional field on the other side
There was a problem hiding this comment.
it has information if the invite is read only or not, if it is read only then the base will wait just to check if pass is updating otherwise if its writeable it will wait to check if the pass has become writable before confirming that the device is paired
| if (existing) { | ||
|
|
||
| if (existing && existing.readOnly !== readOnly) { | ||
| await this.deleteInvite() |
There was a problem hiding this comment.
wonder why don't we keep at most 2 invites in the db?
- one is normal invite
- one is readonly invite
=> use find instead of findOne to get all invites (max 2 invites)
deleteInvite should receive id to delete the correct one
There was a problem hiding this comment.
otherwise, if we create a normal invite, then create a readonly invite, it will delete the other one even before someone pair it
There was a problem hiding this comment.
we intentionally switched to one invite only so that invite expires post use. if user wants to add another user they can invalidate the previous invite and create new one
There was a problem hiding this comment.
yeah that is on purpose
No description provided.