Replace typescript compiler with native tsgo compiler

This commit is contained in:
Jamie
2026-03-18 11:26:18 -07:00
committed by GitHub
parent 5e6af4708b
commit c90ca2b4e0
207 changed files with 1819 additions and 1270 deletions

View File

@@ -151,8 +151,8 @@ type CreateAccountSharedOptionsType = Readonly<{
verificationCode: string;
aciKeyPair: KeyPairType;
pniKeyPair: KeyPairType;
profileKey: Uint8Array;
masterKey: Uint8Array | undefined;
profileKey: Uint8Array<ArrayBuffer>;
masterKey: Uint8Array<ArrayBuffer> | undefined;
accountEntropyPool: string | undefined;
}>;
@@ -164,11 +164,11 @@ type CreatePrimaryDeviceOptionsType = Readonly<{
ourPni?: undefined;
userAgent?: undefined;
ephemeralBackupKey?: undefined;
mediaRootBackupKey: Uint8Array;
mediaRootBackupKey: Uint8Array<ArrayBuffer>;
readReceipts: true;
accessKey: Uint8Array;
accessKey: Uint8Array<ArrayBuffer>;
sessionId: string;
}> &
CreateAccountSharedOptionsType;
@@ -180,8 +180,8 @@ export type CreateLinkedDeviceOptionsType = Readonly<{
ourAci: AciString;
ourPni: PniString;
userAgent?: string;
ephemeralBackupKey: Uint8Array | undefined;
mediaRootBackupKey: Uint8Array | undefined;
ephemeralBackupKey: Uint8Array<ArrayBuffer> | undefined;
mediaRootBackupKey: Uint8Array<ArrayBuffer> | undefined;
readReceipts: boolean;
@@ -250,7 +250,7 @@ function signedPreKeyToUploadSignedPreKey({
export type ConfirmNumberResultType = Readonly<{
deviceName: string;
backupFile: Uint8Array | undefined;
backupFile: Uint8Array<ArrayBuffer> | undefined;
}>;
export default class AccountManager extends EventTarget {

View File

@@ -81,14 +81,14 @@ export async function parseContactsV2(
// while we wait for more chunks to get to the expected avatar size.
// Note: exported only for testing
export class ParseContactsTransform extends DelimitedStream {
protected override getTrailerSize(frame: Buffer): number {
protected override getTrailerSize(frame: Buffer<ArrayBuffer>): number {
const contact = Proto.ContactDetails.decode(frame);
return contact.avatar?.length ?? 0;
}
protected override async pushFrame(
frame: Buffer,
avatarData: Buffer
frame: Buffer<ArrayBuffer>,
avatarData: Buffer<ArrayBuffer>
): Promise<void> {
const contact = Proto.ContactDetails.decode(frame);
@@ -98,7 +98,7 @@ export class ParseContactsTransform extends DelimitedStream {
async function prepareContact(
{ aci: rawAci, aciBinary, ...proto }: Proto.ContactDetails,
avatarData: Uint8Array
avatarData: Uint8Array<ArrayBuffer>
): Promise<ContactDetailsWithAvatar | undefined> {
const expireTimer =
proto.expireTimer != null

View File

@@ -168,14 +168,14 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
public readonly unidentifiedDeliveries?: Array<ServiceIdString>;
public readonly dataMessage: Uint8Array | undefined;
public readonly dataMessage: Uint8Array<ArrayBuffer> | undefined;
public readonly editMessage: Uint8Array | undefined;
public readonly editMessage: Uint8Array<ArrayBuffer> | undefined;
// Fields necessary for send log save
public readonly contentHint?: number;
public readonly contentProto?: Uint8Array;
public readonly contentProto?: Uint8Array<ArrayBuffer>;
public readonly timestamp?: number;

View File

@@ -189,7 +189,7 @@ type UnsealedEnvelope = Readonly<
unidentifiedDeliveryReceived?: boolean;
contentHint?: number;
groupId?: string;
cipherTextBytes?: Uint8Array;
cipherTextBytes?: Uint8Array<ArrayBuffer>;
cipherTextType?: number;
certificate?: SenderCertificate;
unsealedContent?: UnidentifiedSenderMessageContent;
@@ -199,7 +199,7 @@ type UnsealedEnvelope = Readonly<
type DecryptResult = Readonly<
| {
envelope: UnsealedEnvelope;
plaintext: Uint8Array;
plaintext: Uint8Array<ArrayBuffer>;
}
| {
envelope?: UnsealedEnvelope;
@@ -208,12 +208,12 @@ type DecryptResult = Readonly<
>;
type DecryptSealedSenderResult = Readonly<{
plaintext: Uint8Array;
plaintext: Uint8Array<ArrayBuffer>;
wasEncrypted: boolean;
}>;
type InnerDecryptResultType = Readonly<{
plaintext: Uint8Array;
plaintext: Uint8Array<ArrayBuffer>;
wasEncrypted: boolean;
}>;
@@ -999,7 +999,7 @@ export default class MessageReceiver
const decrypted: Array<
Readonly<{
plaintext: Uint8Array;
plaintext: Uint8Array<ArrayBuffer>;
data: UnprocessedType;
envelope: UnsealedEnvelope;
}>
@@ -1207,7 +1207,7 @@ export default class MessageReceiver
async #queueDecryptedEnvelope(
envelope: UnsealedEnvelope,
plaintext: Uint8Array
plaintext: Uint8Array<ArrayBuffer>
): Promise<void> {
const id = getEnvelopeId(envelope);
log.info('queueing decrypted envelope', id);
@@ -1313,7 +1313,7 @@ export default class MessageReceiver
// Called after `decryptEnvelope` decrypted the message.
async #handleDecryptedEnvelope(
envelope: UnsealedEnvelope,
plaintext: Uint8Array
plaintext: Uint8Array<ArrayBuffer>
): Promise<void> {
if (this.#stoppingProcessing) {
return;
@@ -1443,7 +1443,7 @@ export default class MessageReceiver
return { plaintext: undefined, envelope };
}
let ciphertext: Uint8Array;
let ciphertext: Uint8Array<ArrayBuffer>;
if (envelope.content) {
ciphertext = envelope.content;
} else {
@@ -1691,7 +1691,7 @@ export default class MessageReceiver
);
}
#unpad(paddedPlaintext: Uint8Array): Uint8Array {
#unpad(paddedPlaintext: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer> {
for (let i = paddedPlaintext.length - 1; i >= 0; i -= 1) {
if (paddedPlaintext[i] === 0x80) {
return new Uint8Array(paddedPlaintext.subarray(0, i));
@@ -1833,7 +1833,7 @@ export default class MessageReceiver
async #innerDecrypt(
stores: LockedStores,
envelope: UnsealedEnvelope,
ciphertext: Uint8Array,
ciphertext: Uint8Array<ArrayBuffer>,
serviceIdKind: ServiceIdKind
): Promise<InnerDecryptResultType | undefined> {
const {
@@ -1959,7 +1959,7 @@ export default class MessageReceiver
async #decrypt(
stores: LockedStores,
envelope: UnsealedEnvelope,
ciphertext: Uint8Array,
ciphertext: Uint8Array<ArrayBuffer>,
serviceIdKind: ServiceIdKind
): Promise<InnerDecryptResultType | undefined> {
const uuid = envelope.sourceServiceId;
@@ -2591,7 +2591,7 @@ export default class MessageReceiver
async #innerHandleContentMessage(
incomingEnvelope: UnsealedEnvelope,
plaintext: Uint8Array
plaintext: Uint8Array<ArrayBuffer>
): Promise<void> {
const content = Proto.Content.decode(plaintext);
const envelope = await this.#maybeUpdateTimestamp(incomingEnvelope);
@@ -2653,7 +2653,7 @@ export default class MessageReceiver
#handleDecryptionError(
envelope: UnsealedEnvelope,
decryptionError: Uint8Array
decryptionError: Uint8Array<ArrayBuffer>
): void {
const logId = getEnvelopeId(envelope);
log.info(`handleDecryptionError: ${logId}`);
@@ -2688,7 +2688,7 @@ export default class MessageReceiver
async #handleSenderKeyDistributionMessage(
stores: LockedStores,
envelope: UnsealedEnvelope,
distributionMessage: Uint8Array
distributionMessage: Uint8Array<ArrayBuffer>
): Promise<void> {
const envelopeId = getEnvelopeId(envelope);
log.info(`handleSenderKeyDistributionMessage/${envelopeId}`);

View File

@@ -112,7 +112,9 @@ function getPaddedMessageLength(messageLength: number): number {
return messagePartCount * PADDING_BLOCK;
}
export function padMessage(messageBuffer: Uint8Array): Uint8Array {
export function padMessage(
messageBuffer: Uint8Array<ArrayBuffer>
): Uint8Array<ArrayBuffer> {
const plaintext = new Uint8Array(
getPaddedMessageLength(messageBuffer.byteLength + 1) - 1
);
@@ -131,7 +133,7 @@ export default class OutgoingMessage {
callback: (result: CallbackResultType) => void;
plaintext?: Uint8Array;
plaintext?: Uint8Array<ArrayBuffer>;
serviceIdsCompleted: number;
@@ -210,8 +212,8 @@ export default class OutgoingMessage {
const proto = this.message;
const contentProto = this.getContentProtoBytes();
const { timestamp, contentHint, recipients, urgent } = this;
let dataMessage: Uint8Array | undefined;
let editMessage: Uint8Array | undefined;
let dataMessage: Uint8Array<ArrayBuffer> | undefined;
let editMessage: Uint8Array<ArrayBuffer> | undefined;
let hasPniSignatureMessage = false;
if (!(proto instanceof PlaintextContent)) {
@@ -355,7 +357,7 @@ export default class OutgoingMessage {
});
}
getPlaintext(): Uint8Array {
getPlaintext(): Uint8Array<ArrayBuffer> {
if (!this.plaintext) {
const { message } = this;
@@ -368,7 +370,7 @@ export default class OutgoingMessage {
return this.plaintext;
}
getContentProtoBytes(): Uint8Array | undefined {
getContentProtoBytes(): Uint8Array<ArrayBuffer> | undefined {
if (this.message instanceof PlaintextContent) {
return undefined;
}

View File

@@ -39,11 +39,11 @@ export type ProvisionDecryptResult = Readonly<{
provisioningCode?: string;
userAgent?: string;
readReceipts?: boolean;
profileKey?: Uint8Array;
masterKey?: Uint8Array;
profileKey?: Uint8Array<ArrayBuffer>;
masterKey?: Uint8Array<ArrayBuffer>;
accountEntropyPool: string | undefined;
mediaRootBackupKey: Uint8Array | undefined;
ephemeralBackupKey: Uint8Array | undefined;
mediaRootBackupKey: Uint8Array<ArrayBuffer> | undefined;
ephemeralBackupKey: Uint8Array<ArrayBuffer> | undefined;
}>;
class ProvisioningCipherInner {

View File

@@ -161,8 +161,8 @@ export type OutgoingTextAttachmentType = Omit<TextAttachmentType, 'preview'> & {
};
export type GroupV2InfoType = {
groupChange?: Uint8Array;
masterKey: Uint8Array;
groupChange?: Uint8Array<ArrayBuffer>;
masterKey: Uint8Array<ArrayBuffer>;
revision: number;
members: ReadonlyArray<ServiceIdString>;
};
@@ -221,7 +221,7 @@ export type SharedMessageOptionsType = Readonly<{
pinMessage?: SendPinMessageType;
pollCreate?: PollCreateType;
preview?: ReadonlyArray<OutgoingLinkPreviewType>;
profileKey?: Uint8Array;
profileKey?: Uint8Array<ArrayBuffer>;
quote?: OutgoingQuoteType;
reaction?: ReactionType;
sticker?: OutgoingStickerType;
@@ -285,7 +285,7 @@ class Message {
preview?: ReadonlyArray<OutgoingLinkPreviewType>;
profileKey?: Uint8Array;
profileKey?: Uint8Array<ArrayBuffer>;
quote?: OutgoingQuoteType;
@@ -775,7 +775,7 @@ export class MessageSender {
// Attachment upload functions
static getRandomPadding(): Uint8Array {
static getRandomPadding(): Uint8Array<ArrayBuffer> {
// Generate a random int from 1 and 512
const buffer = getRandomBytes(2);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -836,7 +836,7 @@ export class MessageSender {
async getDataOrEditMessage(
options: Readonly<MessageOptionsType>
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
const message = await this.getHydratedMessage(options);
const dataMessage = message.toProto();
@@ -909,7 +909,7 @@ export class MessageSender {
expireTimer,
expireTimerVersion,
pollVote,
}: PollVoteBuildOptions): Promise<Uint8Array> {
}: PollVoteBuildOptions): Promise<Uint8Array<ArrayBuffer>> {
const proto = this.createDataMessageProtoForPollVote({
groupV2,
timestamp,
@@ -1031,7 +1031,7 @@ export class MessageSender {
bodyRanges?: Array<RawBodyRange>;
fileAttachment?: UploadedAttachmentType;
groupV2?: GroupV2InfoType;
profileKey: Uint8Array;
profileKey: Uint8Array<ArrayBuffer>;
textAttachment?: OutgoingTextAttachmentType;
}): Promise<Proto.StoryMessage.Params> {
let attachment: Proto.StoryMessage.Params['attachment'];
@@ -1123,7 +1123,7 @@ export class MessageSender {
getTypingContentMessage(
options: Readonly<{
recipientId?: ServiceIdString;
groupId?: Uint8Array;
groupId?: Uint8Array<ArrayBuffer>;
groupMembers: ReadonlyArray<ServiceIdString>;
isTyping: boolean;
timestamp?: number;
@@ -1505,8 +1505,8 @@ export class MessageSender {
storyMessage,
storyMessageRecipients,
}: Readonly<{
encodedDataMessage?: Uint8Array;
encodedEditMessage?: Uint8Array;
encodedDataMessage?: Uint8Array<ArrayBuffer>;
encodedEditMessage?: Uint8Array<ArrayBuffer>;
timestamp: number;
destinationE164: string | undefined;
destinationServiceId: ServiceIdString | undefined;
@@ -1547,7 +1547,7 @@ export class MessageSender {
): Promise<Proto.SyncMessage.Sent.UnidentifiedDeliveryStatus.Params> => {
const conv = window.ConversationController.get(conversationId);
const serviceId = conv?.getServiceId();
let destinationPniIdentityKey: Uint8Array | null = null;
let destinationPniIdentityKey: Uint8Array<ArrayBuffer> | null = null;
if (conv) {
if (isPniString(serviceId)) {
const pniIdentityKey =
@@ -2221,7 +2221,7 @@ export class MessageSender {
options: Readonly<{
e164s: Array<string>;
acis: Array<AciString>;
groupIds: Array<Uint8Array>;
groupIds: Array<Uint8Array<ArrayBuffer>>;
}>
): SingleProtoJobData {
const myAci = itemStorage.user.getCheckedAci();
@@ -2267,7 +2267,7 @@ export class MessageSender {
static getMessageRequestResponseSync(
options: Readonly<{
threadAci?: AciString;
groupId?: Uint8Array;
groupId?: Uint8Array<ArrayBuffer>;
type: number;
}>
): SingleProtoJobData {
@@ -2362,7 +2362,7 @@ export class MessageSender {
destinationE164: string | undefined,
destinationAci: AciString | undefined,
state: number,
identityKey: Readonly<Uint8Array>
identityKey: Readonly<Uint8Array<ArrayBuffer>>
): SingleProtoJobData {
const myAci = itemStorage.user.getCheckedAci();
@@ -2540,7 +2540,7 @@ export class MessageSender {
static getNullMessage(
options: Readonly<{
padding?: Uint8Array;
padding?: Uint8Array<ArrayBuffer>;
}> = {}
): Proto.Content.Params {
return {
@@ -2570,7 +2570,7 @@ export class MessageSender {
}: Readonly<{
contentHint: number;
messageId?: string;
proto: Uint8Array;
proto: Uint8Array<ArrayBuffer>;
sendType: SendTypesType;
timestamp: number;
urgent: boolean;

View File

@@ -414,10 +414,10 @@ export class SocketManager extends EventListener {
const { method = 'GET', body, timeout, signal } = init;
let bodyBytes: Uint8Array | undefined;
let bodyBytes: Uint8Array<ArrayBuffer> | undefined;
if (body === undefined) {
bodyBytes = undefined;
} else if (body instanceof Uint8Array) {
} else if (Bytes.isNonSharedUint8Array(body)) {
bodyBytes = body;
} else if (body instanceof ArrayBuffer) {
throw new Error('Unsupported body type: ArrayBuffer');

View File

@@ -59,7 +59,7 @@ export type DeviceType = {
export type CompatSignedPreKeyType = {
keyId: number;
keyPair: KeyPairType;
signature: Uint8Array;
signature: Uint8Array<ArrayBuffer>;
};
export type CompatPreKeyType = {
@@ -76,8 +76,8 @@ export type OuterSignedPrekeyType = {
created_at: number;
keyId: number;
privKey: Uint8Array;
pubKey: Uint8Array;
privKey: Uint8Array<ArrayBuffer>;
pubKey: Uint8Array<ArrayBuffer>;
};
export type SessionResetsType = Record<string, number>;
@@ -96,13 +96,13 @@ export type ProcessedEnvelope = Readonly<{
destinationServiceId: ServiceIdString;
updatedPni: PniString | undefined;
timestamp: number;
content: Uint8Array;
content: Uint8Array<ArrayBuffer>;
serverGuid: string;
serverTimestamp: number;
groupId: string | undefined;
urgent: boolean;
story: boolean;
reportingToken: Uint8Array | undefined;
reportingToken: Uint8Array<ArrayBuffer> | undefined;
groupId: string | undefined;
}>;
@@ -277,7 +277,7 @@ export type ProcessedDataMessage = {
export type ProcessedUnidentifiedDeliveryStatus = Readonly<{
destinationServiceId?: ServiceIdString;
isAllowedToReplyToStory?: boolean;
destinationPniIdentityKey?: Uint8Array;
destinationPniIdentityKey?: Uint8Array<ArrayBuffer>;
unidentified?: boolean;
}>;
@@ -306,8 +306,8 @@ export type CallbackResultType = {
failoverServiceIds?: Array<ServiceIdString>;
errors?: Array<CustomError>;
unidentifiedDeliveries?: Array<ServiceIdString>;
dataMessage: Uint8Array | undefined;
editMessage: Uint8Array | undefined;
dataMessage: Uint8Array<ArrayBuffer> | undefined;
editMessage: Uint8Array<ArrayBuffer> | undefined;
// If this send is not the final step in a multi-step send, we shouldn't treat its
// results we would treat a one-step send.
@@ -315,7 +315,7 @@ export type CallbackResultType = {
// Fields necessary for send log save
contentHint?: number;
contentProto?: Uint8Array;
contentProto?: Uint8Array<ArrayBuffer>;
timestamp?: number;
recipients?: Record<ServiceIdString, Array<number>>;
urgent?: boolean;
@@ -328,13 +328,13 @@ export type IRequestHandler = {
};
export type PniKeyMaterialType = Readonly<{
identityKeyPair: Uint8Array;
signedPreKey: Uint8Array;
lastResortKyberPreKey?: Uint8Array;
identityKeyPair: Uint8Array<ArrayBuffer>;
signedPreKey: Uint8Array<ArrayBuffer>;
lastResortKyberPreKey?: Uint8Array<ArrayBuffer>;
registrationId: number;
}>;
export type PniSignatureMessageType = Readonly<{
pni: PniString;
signature: Uint8Array;
signature: Uint8Array<ArrayBuffer>;
}>;

View File

@@ -219,7 +219,7 @@ type PromiseAjaxOptionsType<Type extends ResponseType, OutputShape> = {
certificateAuthority?: string;
chatServiceUrl?: string;
contentType?: string;
data?: Uint8Array | (() => Readable) | string;
data?: Uint8Array<ArrayBuffer> | (() => Readable) | string;
disableRetries?: boolean;
disableSessionResumption?: boolean;
headers?: HeaderListType;
@@ -264,7 +264,7 @@ type JSONWithDetailsType<Data = unknown> = {
response: Response;
};
type BytesWithDetailsType = {
data: Uint8Array;
data: Uint8Array<ArrayBuffer>;
contentType: string | null;
response: Response;
};
@@ -511,7 +511,7 @@ async function _promiseAjax<Type extends ResponseType, OutputShape>(
}
}
let result: string | Uint8Array | Readable | unknown;
let result: string | Uint8Array<ArrayBuffer> | Readable | unknown;
try {
if (DEBUG && !isSuccess(response.status)) {
result = await response.text();
@@ -623,7 +623,10 @@ async function _promiseAjax<Type extends ResponseType, OutputShape>(
log.info(logId, response.status, 'Success');
if (options.responseType === 'byteswithdetails') {
assertDev(result instanceof Uint8Array, 'Expected Uint8Array result');
assertDev(
Bytes.isNonSharedUint8Array(result),
'Expected Uint8Array result'
);
const fullResult: BytesWithDetailsType = {
data: result,
contentType: getContentType(response),
@@ -684,7 +687,7 @@ async function _retry<R>(
type OuterAjaxReturnType<Type extends ResponseType, OutputShape> = {
json: Promise<OutputShape>;
jsonwithdetails: Promise<JSONWithDetailsType<OutputShape>>;
bytes: Promise<Uint8Array>;
bytes: Promise<Uint8Array<ArrayBuffer>>;
byteswithdetails: Promise<BytesWithDetailsType>;
stream: Promise<Readable>;
streamwithdetails: Promise<StreamWithDetailsType>;
@@ -849,7 +852,7 @@ type AjaxOptionsType<Type extends AjaxResponseType, OutputShape = unknown> = (
| AjaxChatOptionsType
) & {
contentType?: string;
data?: Buffer | Uint8Array | string;
data?: Buffer<ArrayBuffer> | Uint8Array<ArrayBuffer> | string;
headers?: HeaderListType;
httpType: HTTPCodeType;
jsonData?: unknown;
@@ -872,7 +875,7 @@ export type WebAPIConnectOptionsType = WebAPICredentials & {
hasBuildExpired: boolean;
};
type StickerPackManifestType = Uint8Array;
type StickerPackManifestType = Uint8Array<ArrayBuffer>;
export type GroupCredentialType = {
credential: string;
@@ -895,7 +898,7 @@ export type GetGroupLogOptionsType = Readonly<{
}>;
export type GroupLogResponseType = {
changes: Proto.GroupChanges;
groupSendEndorsementsResponse: Uint8Array | null;
groupSendEndorsementsResponse: Uint8Array<ArrayBuffer> | null;
} & (
| {
paginated: false;
@@ -968,7 +971,7 @@ export type ProfileType = Readonly<{
}>;
export type GetAccountForUsernameOptionsType = Readonly<{
hash: Uint8Array;
hash: Uint8Array<ArrayBuffer>;
}>;
export type GetAccountForUsernameResultType = AciString | null;
@@ -1045,19 +1048,19 @@ export type VerifyServiceIdResponseType = z.infer<
>;
export type ReserveUsernameOptionsType = Readonly<{
hashes: ReadonlyArray<Uint8Array>;
hashes: ReadonlyArray<Uint8Array<ArrayBuffer>>;
abortSignal?: AbortSignal;
}>;
export type ReplaceUsernameLinkOptionsType = Readonly<{
encryptedUsername: Uint8Array;
encryptedUsername: Uint8Array<ArrayBuffer>;
keepLinkHandle: boolean;
}>;
export type ConfirmUsernameOptionsType = Readonly<{
hash: Uint8Array;
proof: Uint8Array;
encryptedUsername: Uint8Array;
hash: Uint8Array<ArrayBuffer>;
proof: Uint8Array<ArrayBuffer>;
encryptedUsername: Uint8Array<ArrayBuffer>;
abortSignal?: AbortSignal;
}>;
@@ -1085,12 +1088,12 @@ export type ReplaceUsernameLinkResultType = z.infer<
>;
export type ResolveUsernameByLinkOptionsType = Readonly<{
entropy: Uint8Array;
entropy: Uint8Array<ArrayBuffer>;
uuid: string;
}>;
export type ResolveUsernameLinkResultType = {
username: string;
hash: Uint8Array;
hash: Uint8Array<ArrayBuffer>;
} | null;
export type CreateAccountOptionsType = Readonly<{
@@ -1100,7 +1103,7 @@ export type CreateAccountOptionsType = Readonly<{
newPassword: string;
registrationId: number;
pniRegistrationId: number;
accessKey: Uint8Array;
accessKey: Uint8Array<ArrayBuffer>;
aciPublicKey: PublicKey;
pniPublicKey: PublicKey;
aciSignedPreKey: UploadSignedPreKeyType;
@@ -1281,13 +1284,13 @@ export type RequestVerificationResultType = Readonly<{
}>;
export type SetBackupIdOptionsType = Readonly<{
messagesBackupAuthCredentialRequest: Uint8Array;
mediaBackupAuthCredentialRequest: Uint8Array;
messagesBackupAuthCredentialRequest: Uint8Array<ArrayBuffer>;
mediaBackupAuthCredentialRequest: Uint8Array<ArrayBuffer>;
}>;
export type SetBackupSignatureKeyOptionsType = Readonly<{
headers: BackupPresentationHeadersType;
backupIdPublicKey: Uint8Array;
backupIdPublicKey: Uint8Array<ArrayBuffer>;
}>;
export type UploadBackupOptionsType = Readonly<{
@@ -1302,8 +1305,8 @@ export type BackupMediaItemType = Readonly<{
}>;
objectLength: number;
mediaId: string;
hmacKey: Uint8Array;
encryptionKey: Uint8Array;
hmacKey: Uint8Array<ArrayBuffer>;
encryptionKey: Uint8Array<ArrayBuffer>;
}>;
export type BackupMediaBatchOptionsType = Readonly<{
@@ -1505,7 +1508,7 @@ export type ReleaseNotesManifestResponseType = z.infer<
>;
export type GetReleaseNoteImageAttachmentResultType = Readonly<{
imageData: Uint8Array;
imageData: Uint8Array<ArrayBuffer>;
contentType: string | null;
}>;
@@ -1609,7 +1612,7 @@ export type SubscriptionResponseType = z.infer<
export type UploadSignedPreKeyType = {
keyId: number;
publicKey: PublicKey;
signature: Uint8Array;
signature: Uint8Array<ArrayBuffer>;
};
export type UploadPreKeyType = {
keyId: number;
@@ -1618,7 +1621,7 @@ export type UploadPreKeyType = {
export type UploadKyberPreKeyType = {
keyId: number;
publicKey: KEMPublicKey;
signature: Uint8Array;
signature: Uint8Array<ArrayBuffer>;
};
type SerializedSignedPreKeyType = Readonly<{
@@ -1677,20 +1680,20 @@ export type ServerKeysType = {
// We'll get a 404 if none of these keys are provided; we'll have at least one
preKey?: {
keyId: number;
publicKey: Uint8Array;
publicKey: Uint8Array<ArrayBuffer>;
};
signedPreKey?: {
keyId: number;
publicKey: Uint8Array;
signature: Uint8Array;
publicKey: Uint8Array<ArrayBuffer>;
signature: Uint8Array<ArrayBuffer>;
};
pqPreKey?: {
keyId: number;
publicKey: Uint8Array;
signature: Uint8Array;
publicKey: Uint8Array<ArrayBuffer>;
signature: Uint8Array<ArrayBuffer>;
};
}>;
identityKey: Uint8Array;
identityKey: Uint8Array<ArrayBuffer>;
};
export type ChallengeType = {
@@ -1841,7 +1844,9 @@ const fetchForLinkPreviews: linkPreviewFetch.FetchFn = async (href, init) => {
return fetch(href, { ...init, agent: fetchAgent });
};
function _ajax(param: AjaxOptionsType<'bytes', never>): Promise<Uint8Array>;
function _ajax(
param: AjaxOptionsType<'bytes', never>
): Promise<Uint8Array<ArrayBuffer>>;
function _ajax(
param: AjaxOptionsType<'byteswithdetails', never>
): Promise<BytesWithDetailsType>;
@@ -2275,7 +2280,7 @@ export async function getReleaseNoteImageAttachment(
export async function getStorageManifest(
options: StorageServiceCallOptionsType = {}
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
const { credentials, greaterThanVersion } = options;
const { data, response } = await _ajax({
@@ -2302,9 +2307,9 @@ export async function getStorageManifest(
}
export async function getStorageRecords(
data: Uint8Array,
data: Uint8Array<ArrayBuffer>,
options: StorageServiceCallOptionsType = {}
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
const { credentials } = options;
return _ajax({
@@ -2319,9 +2324,9 @@ export async function getStorageRecords(
}
export async function modifyStorageRecords(
data: Uint8Array,
data: Uint8Array<ArrayBuffer>,
options: StorageServiceCallOptionsType = {}
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
const { credentials } = options;
return _ajax({
@@ -2578,7 +2583,7 @@ export async function getProfileUnauth(
export async function getBadgeImageFile(
imageFileUrl: string
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
strictAssert(
isBadgeImageFileUrlValid(imageFileUrl, updatesUrl),
'getBadgeImageFile got an invalid URL. Was bad data saved?'
@@ -2607,7 +2612,7 @@ export async function getBadgeImageFile(
export async function downloadOnboardingStories(
manifestVersion: string,
imageFiles: Array<string>
): Promise<Array<Uint8Array>> {
): Promise<Array<Uint8Array<ArrayBuffer>>> {
return Promise.all(
imageFiles.map(fileName =>
_outerAjax(
@@ -2636,7 +2641,9 @@ export async function getSubscriptionConfiguration(): Promise<SubscriptionConfig
});
}
export async function getAvatar(path: string): Promise<Uint8Array> {
export async function getAvatar(
path: string
): Promise<Uint8Array<ArrayBuffer>> {
// Using _outerAJAX, since it's not hardcoded to the Signal Server. Unlike our
// attachment CDN, it uses our self-signed certificate, so we pass it in.
return _outerAjax(`${cdnUrlObject['0']}/${path}`, {
@@ -2895,11 +2902,11 @@ export async function createAccount({
function asSignedKey<K>(key: {
keyId: number;
publicKey: K;
signature: Uint8Array;
signature: Uint8Array<ArrayBuffer>;
}): {
id: () => number;
publicKey: () => K;
signature: () => Uint8Array;
signature: () => Uint8Array<ArrayBuffer>;
} {
return {
id: () => key.keyId,
@@ -3640,7 +3647,7 @@ function booleanToString(value: boolean | undefined): string {
}
export async function sendMulti(
payload: Uint8Array,
payload: Uint8Array<ArrayBuffer>,
groupSendToken: GroupSendToken | null,
timestamp: number,
{
@@ -3684,8 +3691,8 @@ export async function sendMulti(
}
export async function sendMultiLegacy(
data: Uint8Array,
accessKeys: Uint8Array | null,
data: Uint8Array<ArrayBuffer>,
accessKeys: Uint8Array<ArrayBuffer> | null,
groupSendToken: GroupSendToken | null,
timestamp: number,
{
@@ -3743,7 +3750,7 @@ function redactStickerUrl(stickerUrl: string): string {
export async function getSticker(
packId: string,
stickerId: number
): Promise<Uint8Array> {
): Promise<Uint8Array<ArrayBuffer>> {
if (!isPackIdValid(packId)) {
throw new Error('getSticker: pack ID was invalid');
}
@@ -3796,7 +3803,7 @@ function makePutParams(
policy,
signature,
}: ServerV2AttachmentType,
encryptedBin: Uint8Array
encryptedBin: Uint8Array<ArrayBuffer>
) {
// Note: when using the boundary string in the POST body, it needs to be prefixed by
// an extra --, and the final boundary string at the end gets a -- prefix and a --
@@ -3841,8 +3848,8 @@ function makePutParams(
}
export async function putStickers(
encryptedManifest: Uint8Array,
encryptedStickers: ReadonlyArray<Uint8Array>,
encryptedManifest: Uint8Array<ArrayBuffer>,
encryptedStickers: ReadonlyArray<Uint8Array<ArrayBuffer>>,
onProgress?: () => void
): Promise<string> {
// Get manifest and sticker upload parameters
@@ -4280,7 +4287,7 @@ export async function makeSfuRequest(
targetUrl: string,
type: HTTPCodeType,
headers: HeaderListType,
body: Uint8Array | undefined
body: Uint8Array<ArrayBuffer> | undefined
): Promise<BytesWithDetailsType> {
return _outerAjax(targetUrl, {
certificateAuthority,
@@ -4380,7 +4387,7 @@ function verifyAttributes(attributes: Proto.AvatarUploadAttributes.Params) {
export async function uploadAvatar(
uploadAvatarRequestHeaders: UploadAvatarHeadersType,
avatarData: Uint8Array
avatarData: Uint8Array<ArrayBuffer>
): Promise<string> {
const verified = verifyAttributes(uploadAvatarRequestHeaders);
const { key } = verified;
@@ -4401,7 +4408,7 @@ export async function uploadAvatar(
}
export async function uploadGroupAvatar(
avatarData: Uint8Array,
avatarData: Uint8Array<ArrayBuffer>,
options: GroupCredentialsType
): Promise<string> {
const basicAuth = generateGroupAuth(
@@ -4437,7 +4444,9 @@ export async function uploadGroupAvatar(
return key;
}
export async function getGroupAvatar(key: string): Promise<Uint8Array> {
export async function getGroupAvatar(
key: string
): Promise<Uint8Array<ArrayBuffer>> {
return _outerAjax(`${cdnUrlObject['0']}/${key}`, {
certificateAuthority,
proxyUrl,
@@ -4788,7 +4797,7 @@ export async function getGroupLog(
}
export async function getSubscription(
subscriberId: Uint8Array
subscriberId: Uint8Array<ArrayBuffer>
): Promise<SubscriptionResponseType> {
const formattedId = toWebSafeBase64(Bytes.toBase64(subscriberId));
return _ajax({
@@ -4806,7 +4815,7 @@ export async function getSubscription(
}
export async function getHasSubscription(
subscriberId: Uint8Array
subscriberId: Uint8Array<ArrayBuffer>
): Promise<boolean> {
const data = await getSubscription(subscriberId);
if (!data.subscription) {

View File

@@ -157,7 +157,7 @@ export enum ServerRequestType {
export class IncomingWebSocketRequest {
constructor(
readonly requestType: ServerRequestType,
readonly body: Uint8Array | undefined,
readonly body: Uint8Array<ArrayBuffer> | undefined,
readonly timestamp: number | undefined,
private readonly ack: Pick<ChatServerMessageAck, 'send'> | undefined
) {}
@@ -170,7 +170,7 @@ export class IncomingWebSocketRequest {
export type SendRequestOptions = Readonly<{
verb: string;
path: string;
body?: Uint8Array;
body?: Uint8Array<ArrayBuffer>;
timeout?: number;
headers?: ReadonlyArray<[string, string]>;
}>;
@@ -178,7 +178,7 @@ export type SendRequestOptions = Readonly<{
export type SendRequestResult = Readonly<{
status: number;
message: string;
response?: Uint8Array;
response?: Uint8Array<ArrayBuffer>;
headers: ReadonlyArray<string>;
}>;
@@ -287,7 +287,7 @@ export function connectAuthenticated({
const listener: WebSocketResourceHandler<'auth'> & ChatServiceListener = {
resource: undefined,
onIncomingMessage(
envelope: Uint8Array,
envelope: Uint8Array<ArrayBuffer>,
timestamp: number,
ack: ChatServerMessageAck
): void {

View File

@@ -144,7 +144,7 @@ export class SuccessfulDecryptEvent extends Event {
}
export type DecryptionErrorEventData = Readonly<{
cipherTextBytes: Uint8Array | undefined;
cipherTextBytes: Uint8Array<ArrayBuffer> | undefined;
cipherTextType: number | undefined;
contentHint: number | undefined;
groupId: string | undefined;
@@ -387,15 +387,15 @@ export class FetchLatestEvent extends ConfirmableEvent {
}
export type KeysEventData = Readonly<{
masterKey: Uint8Array | undefined;
masterKey: Uint8Array<ArrayBuffer> | undefined;
accountEntropyPool: string | undefined;
mediaRootBackupKey: Uint8Array | undefined;
mediaRootBackupKey: Uint8Array<ArrayBuffer> | undefined;
}>;
export class KeysEvent extends ConfirmableEvent {
public readonly masterKey: Uint8Array | undefined;
public readonly masterKey: Uint8Array<ArrayBuffer> | undefined;
public readonly accountEntropyPool: string | undefined;
public readonly mediaRootBackupKey: Uint8Array | undefined;
public readonly mediaRootBackupKey: Uint8Array<ArrayBuffer> | undefined;
constructor(
{ masterKey, accountEntropyPool, mediaRootBackupKey }: KeysEventData,
@@ -478,8 +478,8 @@ export class CallEventSyncEvent extends ConfirmableEvent {
export type CallLinkUpdateSyncEventData = Readonly<{
type: CallLinkUpdateSyncType;
rootKey: Uint8Array | undefined;
adminKey: Uint8Array | undefined;
rootKey: Uint8Array<ArrayBuffer> | undefined;
adminKey: Uint8Array<ArrayBuffer> | undefined;
}>;
export class CallLinkUpdateSyncEvent extends ConfirmableEvent {

View File

@@ -9,7 +9,7 @@ import type { ProcessedSent } from './Types.d.ts';
type ProtoServiceId = Readonly<{
destinationServiceId?: string | null;
destinationServiceIdBinary?: Uint8Array | null;
destinationServiceIdBinary?: Uint8Array<ArrayBuffer> | null;
}>;
function processProtoWithDestinationServiceId<Input extends ProtoServiceId>(

View File

@@ -109,7 +109,7 @@ export class Blocked {
public getBlockedData(): {
e164s: Array<string>;
acis: Array<AciString>;
groupIds: Array<Uint8Array>;
groupIds: Array<Uint8Array<ArrayBuffer>>;
} {
const e164s = this.getBlockedNumbers();
const acis = this.getBlockedServiceIds().filter(item => isAciString(item));