Lox module doesn't include trusted invitation redemption
I have been working on updating the Lox module to account for key rotations and noticed that the `redeem` endpoint is never called for trusted invitations.
In Lox there are 2 types of invitations that are handled quite differently. Open invitations are issued to untrusted users by (in our case) the Lox Authority through telegram. Trusted invitations are generated by trusted users and can be handed out, in limited numbers, to friends.
The invitation_is_trusted()
function was implemented to help determine whether an invitation is a trusted invitation, not a trusted invitation or not an invitation at all. With that, and assuming the user has an invitation the workflow should be something like (excuse my butchered javascript):
let invite = receivedInvite;
try {
if (lazy.invitation_is_trusted(invite)) {
let request = await lazy.redeem_invite(JSON.parse(invite).invite, this.#pubkeys);
let response = await this.#makeRequest(
"redeem",
JSON.parse(request).request
);
...
} else {
let request = await lazy.open_invite(JSON.parse(invite).invite);
let response = await this.#makeRequest(
"openreq",
JSON.parse(request).request
);
lazy.logger.debug("openreq response: ", response);
if (response.hasOwnProperty("error")) {
throw new LoxError(
`Error response to "openreq": ${response.error}`,
LoxError.BadInvite
);
}
} catch (err) {
lazy.logger.info(`Does not parse as an invite: "${invite}".`, err);
return false;
}
This is somewhat related to #42453