Switch to libsignal's accountExists.

This commit is contained in:
andrew-signal
2026-02-12 20:49:02 -05:00
committed by GitHub
parent ce95b6dfce
commit 5655b0d502

View File

@@ -15,12 +15,14 @@ import { v4 as getGuid } from 'uuid';
import { z } from 'zod'; import { z } from 'zod';
import type { Readable } from 'node:stream'; import type { Readable } from 'node:stream';
import qs from 'node:querystring'; import qs from 'node:querystring';
import { LibSignalErrorBase, ErrorCode } from '@signalapp/libsignal-client'; import {
import type { LibSignalErrorBase,
KEMPublicKey, ErrorCode,
PublicKey, ServiceId,
Aci, type KEMPublicKey,
Pni, type PublicKey,
type Aci,
type Pni,
} from '@signalapp/libsignal-client'; } from '@signalapp/libsignal-client';
import { AccountAttributes } from '@signalapp/libsignal-client/dist/net.js'; import { AccountAttributes } from '@signalapp/libsignal-client/dist/net.js';
import type { import type {
@@ -736,7 +738,6 @@ export function makeKeysLowercase<V>(
} }
const CHAT_CALLS = { const CHAT_CALLS = {
accountExistence: 'v1/accounts/account',
attachmentUploadForm: 'v4/attachments/form/upload', attachmentUploadForm: 'v4/attachments/form/upload',
attestation: 'v1/attestation', attestation: 'v1/attestation',
batchIdentityCheck: 'v1/profile/identity_check/batch', batchIdentityCheck: 'v1/profile/identity_check/batch',
@@ -2784,24 +2785,12 @@ export async function requestVerification(
export async function checkAccountExistence( export async function checkAccountExistence(
serviceId: ServiceIdString serviceId: ServiceIdString
): Promise<boolean> { ): Promise<boolean> {
try { return _retry(async () => {
await _ajax({ const chat = await socketManager.getUnauthenticatedApi();
host: 'chatService', return chat.accountExists({
httpType: 'HEAD', account: ServiceId.parseFromServiceIdString(serviceId),
call: 'accountExistence',
urlParameters: `/${serviceId}`,
unauthenticated: true,
accessKey: undefined,
groupSendToken: undefined,
}); });
return true; });
} catch (error) {
if (error instanceof HTTPError && error.code === 404) {
return false;
}
throw error;
}
} }
export function startRegistration(): unknown { export function startRegistration(): unknown {