import type { ReadonlyDeep } from 'type-fest'; import * as Native from '../Native.js'; import { type TokioAsyncContext } from '../net.js'; import { PublicKey } from '../EcKeys.js'; import { Aci, Pni } from '../Address.js'; import { SignedKyberPublicPreKey, SignedPublicPreKey } from '../index.js'; import { FakeChatRemote } from './FakeChat.js'; type ConnectionManager = Native.Wrapper; type RegistrationOptions = { tokioAsyncContext: TokioAsyncContext; connectionManager: ConnectionManager; }; export type RegistrationSessionState = { allowedToRequestCode: boolean; verified: boolean; nextSmsSecs?: number; nextCallSecs?: number; nextVerificationAttemptSecs?: number; requestedInformation: Set<'pushChallenge' | 'captcha'>; }; type CreateSessionArgs = Readonly<{ e164: string; }>; type ResumeSessionArgs = Readonly<{ sessionId: string; e164: string; }>; export type Svr2CredentialResult = 'match' | 'no-match' | 'invalid'; /** * A client for the Signal registration service. * * This wraps a {@link Net} to provide a reliable registration service client. */ export declare class RegistrationService { readonly _nativeHandle: Native.RegistrationService; private readonly tokioAsyncContext; private constructor(); /** * The stable identifier for the session. * * This can be persisted and used later for resuming a session that was * interrupted. */ get sessionId(): string; /** * The last known state of the session. * * The state received from the server is stored internally and is exposed via * this property. */ get sessionState(): RegistrationSessionState; /** * Resumes a previously created registration session. * * Asynchronously connects to the registration session and verifies that the * session is still available. If so, returns an initialized * `RegistrationService`. Otherwise the returned `Promise` is resolved with an * error. * * Clients should not use this method directly, but should instead call * {@link Net.resumeRegistrationSession}. * * @returns a `Promise` that resolves to the `RegistrationService` if * resumption is successful, otherwise a {@link LibSignalError}. */ static resumeSession(options: ReadonlyDeep, { sessionId, e164 }: ResumeSessionArgs): Promise; /** * Starts a new registration session. * * Asynchronously connects to the registration session and requests a new session. * If successful, returns an initialized `RegistrationService`. Otherwise the * returned `Promise` is resolved with an error. * * Clients should not use this method directly, but should instead call * {@link Net.createRegistrationSession}. * * @returns a `Promise` that resolves to the `RegistrationService` if * creation is successful, otherwise a {@link RateLimitedError} or other * {@link LibSignalError}. */ static createSession(options: ReadonlyDeep, { e164 }: CreateSessionArgs): Promise; submitCaptcha(captcha: string): Promise<{ allowedToRequestCode: boolean; }>; /** * Request that a verification code be sent via the given transport method. * * With the websocket transport, this makes a POST request to * `/v1/verification/session/{sessionId}/code`. * * The `languages` parameter should be a list of languages in Accept-Language syntax. Note that * "quality weighting" can be left out; the Signal server will always consider the list to be in * priority order. */ requestVerification({ transport, client, languages, }: { transport: 'sms' | 'voice'; client: string; languages: string[]; }): Promise; verifySession(code: string): Promise; checkSvr2Credentials(svr2Tokens: Array): Promise>; registerAccount(inputs: { accountPassword: string; skipDeviceTransfer: boolean; accountAttributes: AccountAttributes; aciPublicKey: PublicKey; pniPublicKey: PublicKey; aciSignedPreKey: SignedPublicPreKey; pniSignedPreKey: SignedPublicPreKey; aciPqLastResortPreKey: SignedKyberPublicPreKey; pniPqLastResortPreKey: SignedKyberPublicPreKey; }): Promise; static reregisterAccount(options: ReadonlyDeep, inputs: { e164: string; accountPassword: string; skipDeviceTransfer: boolean; accountAttributes: AccountAttributes; aciPublicKey: PublicKey; pniPublicKey: PublicKey; aciSignedPreKey: SignedPublicPreKey; pniSignedPreKey: SignedPublicPreKey; aciPqLastResortPreKey: SignedKyberPublicPreKey; pniPqLastResortPreKey: SignedKyberPublicPreKey; }): Promise; /** * Internal, only public for testing */ static _convertNativeSessionState(session: Native.Wrapper): RegistrationSessionState; /** * Create a registration client that sends requests to the returned fake chat. * * Calling code will need to await and use the returned fake chat remote * to respond in order for the returned Promise to resolve. * * Internal, only public for testing */ static fakeCreateSession(tokio: TokioAsyncContext, { e164 }: CreateSessionArgs): [Promise, Promise]; } export declare class AccountAttributes { readonly _nativeHandle: Native.RegistrationAccountAttributes; constructor({ recoveryPassword, aciRegistrationId, pniRegistrationId, registrationLock, unidentifiedAccessKey, unrestrictedUnidentifiedAccess, capabilities, discoverableByPhoneNumber, }: { recoveryPassword: Uint8Array; aciRegistrationId: number; pniRegistrationId: number; registrationLock: string | null; unidentifiedAccessKey: Uint8Array; unrestrictedUnidentifiedAccess: boolean; capabilities: Set; discoverableByPhoneNumber: boolean; }); } export declare class RegisterAccountResponse { readonly _nativeHandle: Native.RegisterAccountResponse; constructor(_nativeHandle: Native.RegisterAccountResponse); get aci(): Aci; get pni(): Pni; get number(): string; get usernameHash(): Uint8Array | null; get usernameLinkHandle(): Uint8Array | null; get backupEntitlement(): { backupLevel: bigint; expirationSeconds: bigint; } | null; get entitlementBadges(): Array<{ id: string; expirationSeconds: number; visible: boolean; }>; get reregistration(): boolean; get storageCapable(): boolean; } export {};