mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 19:08:04 +01:00
Faster incremental builds
This commit is contained in:
@@ -3,59 +3,20 @@
|
||||
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import type { Response } from 'node-fetch';
|
||||
import type { LibSignalErrorBase } from '@signalapp/libsignal-client';
|
||||
|
||||
import { parseRetryAfter } from '../util/parseRetryAfter.js';
|
||||
import type { ServiceIdString } from '../types/ServiceId.js';
|
||||
import type { HTTPError } from '../types/HTTPError.js';
|
||||
import type { HeaderListType } from '../types/WebAPI.d.ts';
|
||||
|
||||
import type { CallbackResultType } from './Types.d.ts';
|
||||
import type { HeaderListType } from './WebAPI.js';
|
||||
|
||||
function appendStack(newError: Error, originalError: Error) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
newError.stack += `\nOriginal stack:\n${originalError.stack}`;
|
||||
}
|
||||
|
||||
export class HTTPError extends Error {
|
||||
public override readonly name = 'HTTPError';
|
||||
|
||||
public readonly code: number;
|
||||
|
||||
public readonly responseHeaders: HeaderListType;
|
||||
|
||||
public readonly response: unknown;
|
||||
|
||||
static fromResponse(response: Response): HTTPError {
|
||||
return new HTTPError(response.statusText, {
|
||||
code: response.status,
|
||||
headers: Object.fromEntries(response.headers),
|
||||
response,
|
||||
});
|
||||
}
|
||||
|
||||
constructor(
|
||||
message: string,
|
||||
options: {
|
||||
code: number;
|
||||
headers: HeaderListType;
|
||||
response?: unknown;
|
||||
stack?: string;
|
||||
cause?: unknown;
|
||||
}
|
||||
) {
|
||||
super(`${message}; code: ${options.code}`, { cause: options.cause });
|
||||
|
||||
const { code: providedCode, headers, response, stack } = options;
|
||||
|
||||
this.code = providedCode > 999 || providedCode < 100 ? -1 : providedCode;
|
||||
this.responseHeaders = headers;
|
||||
|
||||
this.stack += `\nOriginal stack:\n${stack}`;
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
|
||||
export class ReplayableError extends Error {
|
||||
functionCode?: number;
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ import {
|
||||
SendMessageNetworkError,
|
||||
SendMessageChallengeError,
|
||||
UnregisteredUserError,
|
||||
HTTPError,
|
||||
} from './Errors.js';
|
||||
import type { CallbackResultType, CustomError } from './Types.d.ts';
|
||||
import { Address } from '../types/Address.js';
|
||||
import * as Errors from '../types/errors.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import { QualifiedAddress } from '../types/QualifiedAddress.js';
|
||||
import type { ServiceIdString } from '../types/ServiceId.js';
|
||||
import { Sessions, IdentityKeys } from '../LibSignalStores.js';
|
||||
|
||||
@@ -61,10 +61,10 @@ import { getRandomBytes } from '../Crypto.js';
|
||||
import {
|
||||
MessageError,
|
||||
SendMessageProtoError,
|
||||
HTTPError,
|
||||
NoSenderKeyError,
|
||||
} from './Errors.js';
|
||||
import { BodyRange } from '../types/BodyRange.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import type { RawBodyRange } from '../types/BodyRange.js';
|
||||
import type { StoryContextType } from '../types/Util.js';
|
||||
import type {
|
||||
|
||||
@@ -28,6 +28,7 @@ import { drop } from '../util/drop.js';
|
||||
import type { ProxyAgent } from '../util/createProxyAgent.js';
|
||||
import { createProxyAgent } from '../util/createProxyAgent.js';
|
||||
import { type SocketInfo, SocketStatus } from '../types/SocketStatus.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import * as Errors from '../types/errors.js';
|
||||
import * as Bytes from '../Bytes.js';
|
||||
import { createLogger } from '../logging/log.js';
|
||||
@@ -42,7 +43,7 @@ import WebSocketResource, {
|
||||
connectUnauthenticatedLibsignal,
|
||||
ServerRequestType,
|
||||
} from './WebsocketResources.js';
|
||||
import { ConnectTimeoutError, HTTPError } from './Errors.js';
|
||||
import { ConnectTimeoutError } from './Errors.js';
|
||||
import type { IRequestHandler, WebAPICredentials } from './Types.d.ts';
|
||||
import { connect as connectWebSocket } from './WebSocket.js';
|
||||
import { type ServerAlert } from '../util/handleServerAlerts.js';
|
||||
|
||||
2
ts/textsecure/Types.d.ts
vendored
2
ts/textsecure/Types.d.ts
vendored
@@ -11,7 +11,7 @@ import type {
|
||||
PniString,
|
||||
} from '../types/ServiceId.js';
|
||||
import type { TextAttachmentType } from '../types/Attachment.js';
|
||||
import type { GiftBadgeStates } from '../components/conversation/Message.js';
|
||||
import type { GiftBadgeStates } from '../types/GiftBadgeStates.js';
|
||||
import type { MIMEType } from '../types/MIME.js';
|
||||
import type { DurationInSeconds } from '../util/durations/index.js';
|
||||
import type { AnyPaymentEvent } from '../types/Payment.js';
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as Registration from '../util/registration.js';
|
||||
import { ServiceIdKind } from '../types/ServiceId.js';
|
||||
import { createLogger } from '../logging/log.js';
|
||||
import * as Errors from '../types/errors.js';
|
||||
import { HTTPError } from './Errors.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
|
||||
const log = createLogger('UpdateKeysListener');
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { HTTPError } from './Errors.js';
|
||||
import type { HTTPError } from '../types/HTTPError.js';
|
||||
|
||||
export async function handleStatusCode(status: number): Promise<void> {
|
||||
if (status === 499) {
|
||||
|
||||
@@ -36,6 +36,7 @@ import { createProxyAgent } from '../util/createProxyAgent.js';
|
||||
import type { ProxyAgent } from '../util/createProxyAgent.js';
|
||||
import type { FetchFunctionType } from '../util/uploads/tusProtocol.js';
|
||||
import { VerificationTransport } from '../types/VerificationTransport.js';
|
||||
import type { HeaderListType } from '../types/WebAPI.d.ts';
|
||||
import { ZERO_ACCESS_KEY } from '../types/SealedSender.js';
|
||||
import { toLogFormat } from '../types/errors.js';
|
||||
import { isPackIdValid, redactPackId } from '../util/Stickers.js';
|
||||
@@ -51,6 +52,7 @@ import {
|
||||
untaggedPniSchema,
|
||||
} from '../types/ServiceId.js';
|
||||
import type { BackupPresentationHeadersType } from '../types/backups.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import * as Bytes from '../Bytes.js';
|
||||
import { getRandomBytes, randomInt } from '../Crypto.js';
|
||||
import * as linkPreviewFetch from '../linkPreviews/linkPreviewFetch.js';
|
||||
@@ -66,7 +68,6 @@ import { CDSI } from './cds/CDSI.js';
|
||||
import { SignalService as Proto } from '../protobuf/index.js';
|
||||
import { isEnabled as isRemoteConfigEnabled } from '../RemoteConfig.js';
|
||||
|
||||
import { HTTPError } from './Errors.js';
|
||||
import type MessageSender from './SendMessage.js';
|
||||
import type {
|
||||
WebAPICredentials,
|
||||
@@ -172,7 +173,6 @@ function getContentType(response: Response) {
|
||||
}
|
||||
|
||||
type FetchHeaderListType = { [name: string]: string };
|
||||
export type HeaderListType = { [name: string]: string | ReadonlyArray<string> };
|
||||
type HTTPCodeType = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD';
|
||||
|
||||
type RedactUrl = (url: string) => string;
|
||||
|
||||
@@ -12,9 +12,10 @@ import { getUserAgent } from '../util/getUserAgent.js';
|
||||
import * as durations from '../util/durations/index.js';
|
||||
import type { ProxyAgent } from '../util/createProxyAgent.js';
|
||||
import { createHTTPSAgent } from '../util/createHTTPSAgent.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import { createLogger } from '../logging/log.js';
|
||||
import * as Timers from '../Timers.js';
|
||||
import { ConnectTimeoutError, HTTPError } from './Errors.js';
|
||||
import { ConnectTimeoutError } from './Errors.js';
|
||||
import { handleStatusCode, translateError } from './Utils.js';
|
||||
|
||||
const { client: WebSocketClient } = ws;
|
||||
|
||||
@@ -12,12 +12,12 @@ import fsExtra from 'fs-extra';
|
||||
import { createLogger } from '../logging/log.js';
|
||||
import * as Errors from '../types/errors.js';
|
||||
import { strictAssert } from '../util/assert.js';
|
||||
import { hasRequiredInformationForBackup } from '../util/Attachment.js';
|
||||
import {
|
||||
AttachmentSizeError,
|
||||
type AttachmentType,
|
||||
AttachmentVariant,
|
||||
AttachmentPermanentlyUndownloadableError,
|
||||
hasRequiredInformationForBackup,
|
||||
type BackupableAttachmentType,
|
||||
} from '../types/Attachment.js';
|
||||
import * as Bytes from '../Bytes.js';
|
||||
@@ -49,9 +49,9 @@ import { MAX_BACKUP_THUMBNAIL_SIZE } from '../types/VisualAttachment.js';
|
||||
import { missingCaseError } from '../util/missingCaseError.js';
|
||||
import { IV_LENGTH, MAC_LENGTH } from '../types/Crypto.js';
|
||||
import { BackupCredentialType } from '../types/backups.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import { getValue } from '../RemoteConfig.js';
|
||||
import { parseIntOrThrow } from '../util/parseIntOrThrow.js';
|
||||
import { HTTPError } from './Errors.js';
|
||||
|
||||
const { ensureFile } = fsExtra;
|
||||
|
||||
|
||||
@@ -11,11 +11,7 @@ import {
|
||||
PublicKey,
|
||||
} from '@signalapp/libsignal-client';
|
||||
|
||||
import {
|
||||
OutgoingIdentityKeyError,
|
||||
UnregisteredUserError,
|
||||
HTTPError,
|
||||
} from './Errors.js';
|
||||
import { OutgoingIdentityKeyError, UnregisteredUserError } from './Errors.js';
|
||||
import { Sessions, IdentityKeys } from '../LibSignalStores.js';
|
||||
import { Address } from '../types/Address.js';
|
||||
import { QualifiedAddress } from '../types/QualifiedAddress.js';
|
||||
@@ -24,6 +20,7 @@ import type { ServerKeysType, WebAPIType } from './WebAPI.js';
|
||||
import { createLogger } from '../logging/log.js';
|
||||
import { isRecord } from '../util/isRecord.js';
|
||||
import type { GroupSendToken } from '../types/GroupSendEndorsements.js';
|
||||
import { HTTPError } from '../types/HTTPError.js';
|
||||
import { onFailedToSendWithEndorsements } from '../util/groupSendEndorsements.js';
|
||||
|
||||
const log = createLogger('getKeysForServiceId');
|
||||
|
||||
@@ -29,7 +29,7 @@ import type {
|
||||
ProcessedGiftBadge,
|
||||
ProcessedStoryContext,
|
||||
} from './Types.d.ts';
|
||||
import { GiftBadgeStates } from '../components/conversation/Message.js';
|
||||
import { GiftBadgeStates } from '../types/GiftBadgeStates.js';
|
||||
import { APPLICATION_OCTET_STREAM, stringToMIMEType } from '../types/MIME.js';
|
||||
import { SECOND, DurationInSeconds } from '../util/durations/index.js';
|
||||
import type { AnyPaymentEvent } from '../types/Payment.js';
|
||||
@@ -37,7 +37,7 @@ import { PaymentEventKind } from '../types/Payment.js';
|
||||
import { filterAndClean } from '../types/BodyRange.js';
|
||||
import { bytesToUuid } from '../util/uuidToBytes.js';
|
||||
import { createName } from '../util/attachmentPath.js';
|
||||
import { partitionBodyAndNormalAttachments } from '../types/Attachment.js';
|
||||
import { partitionBodyAndNormalAttachments } from '../util/Attachment.js';
|
||||
import { isNotNil } from '../util/isNotNil.js';
|
||||
|
||||
const { isNumber } = lodash;
|
||||
|
||||
Reference in New Issue
Block a user