import ByteArray from '../internal/ByteArray.js'; import GroupSecretParams from '../groups/GroupSecretParams.js'; import ServerPublicParams from '../ServerPublicParams.js'; import UuidCiphertext from '../groups/UuidCiphertext.js'; import { Aci, ServiceId } from '../../Address.js'; import GroupSendDerivedKeyPair from './GroupSendDerivedKeyPair.js'; import GroupSendEndorsement from './GroupSendEndorsement.js'; /** * A collection of endorsements known to be valid. * * The result of the `receive` operations on {@link GroupSendEndorsementsResponse}. Contains an * endorsement for each member of the group, in the same order they were originally provided, plus a * combined endorsement for "everyone but me", intended for multi-recipient sends. */ export type ReceivedEndorsements = { endorsements: GroupSendEndorsement[]; combinedEndorsement: GroupSendEndorsement; }; /** * A set of endorsements of the members in a group, along with a proof of their validity. * * Issued by the group server based on the group's member ciphertexts. The endorsements will * eventually be verified by the chat server in the form of {@link GroupSendFullToken}s. See * {@link GroupSendEndorsement} for a full description of the endorsement flow from the client's * perspective. */ export default class GroupSendEndorsementsResponse extends ByteArray { constructor(contents: Uint8Array); /** * Issues a new set of endorsements for `groupMembers`. * * `groupMembers` should include `requestingUser` as well. */ static issue(groupMembers: UuidCiphertext[], keyPair: GroupSendDerivedKeyPair): GroupSendEndorsementsResponse; /** * Issues a new set of endorsements for `groupMembers`, with an explicity-chosen expiration and * source of randomness. * * Should only be used for testing purposes. * * @see {@link GroupSendEndorsementsResponse#issue} */ static issueWithRandom(groupMembers: UuidCiphertext[], keyPair: GroupSendDerivedKeyPair, random: Uint8Array): GroupSendEndorsementsResponse; /** Returns the expiration for the contained endorsements. */ getExpiration(): Date; /** * Receives, validates, and extracts the endorsements from a response. * * Note that the `receive` operation is provided for both {@link ServiceId}s and {@link * UuidCiphertext}s. If you already have the ciphertexts for the group members available, {@link * #receiveWithCiphertexts} should be faster; if you don't, this method is faster than generating * the ciphertexts and throwing them away afterwards. * * `localUser` should be included in `groupMembers`. * * @throws {VerificationFailedError} if the endorsements are not valid for any reason */ receiveWithServiceIds(groupMembers: ServiceId[], localUser: Aci, groupParams: GroupSecretParams, serverParams: ServerPublicParams, now?: Date): ReceivedEndorsements; /** * Receives, validates, and extracts the endorsements from a response. * * Note that the `receive` operation is provided for both {@link ServiceId}s and {@link * UuidCiphertext}s. If you already have the ciphertexts for the group members available, this * method should be faster; if you don't, {@link #receiveWithServiceIds} is faster than generating * the ciphertexts and throwing them away afterwards. * * `localUser` should be included in `groupMembers`. * * @throws {VerificationFailedError} if the endorsements are not valid for any reason */ receiveWithCiphertexts(groupMembers: UuidCiphertext[], localUser: UuidCiphertext, serverParams: ServerPublicParams, now?: Date): ReceivedEndorsements; }