Skip to content

[Feature] Add read only invites#20

Merged
supersuryaansh merged 3 commits intomainfrom
READ_ONLY_INVITES
Feb 16, 2026
Merged

[Feature] Add read only invites#20
supersuryaansh merged 3 commits intomainfrom
READ_ONLY_INVITES

Conversation

@supersuryaansh
Copy link
Copy Markdown
Member

No description provided.

Comment thread index.js
const existing = await this.base.view.findOne('@autopass/invite', {})
if (existing) {
if (this.member) await this.member.flushed()
return z32.encode(existing.invite)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the existing invite to distinguish readonly and normal invite

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging, makes sense since invites are deleted only once they are used, let me fix this so the flow is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment thread index.js

await this.pass.deleteInvite()
}
const readOnly = JSON.parse(result.data.toString()).readOnly
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curios question,

in the confirm side, we set an object of { key, encryptionKey, additional }

where is the result.data coming from?

Copy link
Copy Markdown
Member Author

@supersuryaansh supersuryaansh Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it comes from additional field

Comment thread index.js
key: this.base.key,
encryptionKey: this.base.encryptionKey
encryptionKey: this.base.encryptionKey,
additional: inv.additional
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result.data comes from additional field on the other side

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread index.js
if (existing) {

if (existing && existing.readOnly !== readOnly) {
await this.deleteInvite()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise, if we create a normal invite, then create a readonly invite, it will delete the other one even before someone pair it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that is on purpose

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah all good then

@supersuryaansh supersuryaansh merged commit 0b0ad3d into main Feb 16, 2026
3 checks passed
@supersuryaansh supersuryaansh deleted the READ_ONLY_INVITES branch February 16, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants