@signalapp/libsignal-client 0.67.4 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Native.d.ts +22 -0
- package/dist/MessageBackup.js +11 -3
- package/dist/io.d.ts +6 -0
- package/dist/io.js +8 -0
- package/dist/net/Chat.d.ts +9 -0
- package/dist/net/Chat.js +21 -2
- package/dist/net/Registration.d.ts +88 -0
- package/dist/net/Registration.js +105 -0
- package/dist/net.d.ts +10 -0
- package/dist/net.js +16 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/darwin-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/linux-x64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-arm64/@signalapp+libsignal-client.node +0 -0
- package/prebuilds/win32-x64/@signalapp+libsignal-client.node +0 -0
package/Native.d.ts
CHANGED
|
@@ -130,6 +130,8 @@ type ChatListener = {
|
|
|
130
130
|
): void;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
type RequestedInformation = 'pushChallenge' | 'captcha';
|
|
134
|
+
|
|
133
135
|
type Wrapper<T> = Readonly<{
|
|
134
136
|
_nativeHandle: T;
|
|
135
137
|
}>;
|
|
@@ -406,6 +408,21 @@ export function ReceiptCredentialResponse_CheckValidContents(buffer: Buffer): vo
|
|
|
406
408
|
export function ReceiptCredential_CheckValidContents(buffer: Buffer): void;
|
|
407
409
|
export function ReceiptCredential_GetReceiptExpirationTime(receiptCredential: Serialized<ReceiptCredential>): Timestamp;
|
|
408
410
|
export function ReceiptCredential_GetReceiptLevel(receiptCredential: Serialized<ReceiptCredential>): bigint;
|
|
411
|
+
export function RegistrationService_CreateSession(asyncRuntime: Wrapper<TokioAsyncContext>, createSession: CreateSession, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
|
|
412
|
+
export function RegistrationService_RegistrationSession(service: Wrapper<RegistrationService>): RegistrationSession;
|
|
413
|
+
export function RegistrationService_RequestPushChallenge(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, pushToken: string, pushTokenType: PushTokenType): CancellablePromise<void>;
|
|
414
|
+
export function RegistrationService_RequestVerificationCode(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, transport: string, client: string): CancellablePromise<void>;
|
|
415
|
+
export function RegistrationService_ResumeSession(asyncRuntime: Wrapper<TokioAsyncContext>, sessionId: string, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
|
|
416
|
+
export function RegistrationService_SessionId(service: Wrapper<RegistrationService>): string;
|
|
417
|
+
export function RegistrationService_SubmitCaptcha(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, captchaValue: string): CancellablePromise<void>;
|
|
418
|
+
export function RegistrationService_SubmitPushChallenge(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, pushChallenge: string): CancellablePromise<void>;
|
|
419
|
+
export function RegistrationService_SubmitVerificationCode(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, code: string): CancellablePromise<void>;
|
|
420
|
+
export function RegistrationSession_GetAllowedToRequestCode(session: Wrapper<RegistrationSession>): boolean;
|
|
421
|
+
export function RegistrationSession_GetNextCallSeconds(session: Wrapper<RegistrationSession>): number | null;
|
|
422
|
+
export function RegistrationSession_GetNextSmsSeconds(session: Wrapper<RegistrationSession>): number | null;
|
|
423
|
+
export function RegistrationSession_GetNextVerificationAttemptSeconds(session: Wrapper<RegistrationSession>): number | null;
|
|
424
|
+
export function RegistrationSession_GetRequestedInformation(session: Wrapper<RegistrationSession>): RequestedInformation[];
|
|
425
|
+
export function RegistrationSession_GetVerified(session: Wrapper<RegistrationSession>): boolean;
|
|
409
426
|
export function SanitizedMetadata_GetDataLen(sanitized: Wrapper<SanitizedMetadata>): bigint;
|
|
410
427
|
export function SanitizedMetadata_GetDataOffset(sanitized: Wrapper<SanitizedMetadata>): bigint;
|
|
411
428
|
export function SanitizedMetadata_GetMetadata(sanitized: Wrapper<SanitizedMetadata>): Buffer;
|
|
@@ -522,6 +539,7 @@ export function TESTING_CdsiLookupErrorConvert(errorDescription: string): void;
|
|
|
522
539
|
export function TESTING_CdsiLookupResponseConvert(asyncRuntime: Wrapper<TokioAsyncContext>): CancellablePromise<LookupResponse>;
|
|
523
540
|
export function TESTING_ChatConnectErrorConvert(errorDescription: string): void;
|
|
524
541
|
export function TESTING_ChatRequestGetBody(request: Wrapper<HttpRequest>): Buffer;
|
|
542
|
+
export function TESTING_ChatRequestGetHeaderNames(request: Wrapper<HttpRequest>): string[];
|
|
525
543
|
export function TESTING_ChatRequestGetHeaderValue(request: Wrapper<HttpRequest>, headerName: string): string;
|
|
526
544
|
export function TESTING_ChatRequestGetMethod(request: Wrapper<HttpRequest>): string;
|
|
527
545
|
export function TESTING_ChatRequestGetPath(request: Wrapper<HttpRequest>): string;
|
|
@@ -538,6 +556,7 @@ export function TESTING_ErrorOnReturnSync(_needsCleanup: null): null;
|
|
|
538
556
|
export function TESTING_FakeChatConnection_Create(tokio: Wrapper<TokioAsyncContext>, listener: ChatListener, alertsJoinedByNewlines: string): FakeChatConnection;
|
|
539
557
|
export function TESTING_FakeChatConnection_TakeAuthenticatedChat(chat: Wrapper<FakeChatConnection>): AuthenticatedChatConnection;
|
|
540
558
|
export function TESTING_FakeChatConnection_TakeRemote(chat: Wrapper<FakeChatConnection>): FakeChatRemoteEnd;
|
|
559
|
+
export function TESTING_FakeChatConnection_TakeUnauthenticatedChat(chat: Wrapper<FakeChatConnection>): UnauthenticatedChatConnection;
|
|
541
560
|
export function TESTING_FakeChatRemoteEnd_InjectConnectionInterrupted(chat: Wrapper<FakeChatRemoteEnd>): void;
|
|
542
561
|
export function TESTING_FakeChatRemoteEnd_ReceiveIncomingRequest(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<FakeChatRemoteEnd>): CancellablePromise<FakeChatSentRequest | null>;
|
|
543
562
|
export function TESTING_FakeChatRemoteEnd_SendRawServerRequest(chat: Wrapper<FakeChatRemoteEnd>, bytes: Buffer): void;
|
|
@@ -565,6 +584,7 @@ export function TESTING_PanicOnReturnAsync(_needsCleanup: null): Promise<null>;
|
|
|
565
584
|
export function TESTING_PanicOnReturnIo(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, _needsCleanup: null): CancellablePromise<null>;
|
|
566
585
|
export function TESTING_PanicOnReturnSync(_needsCleanup: null): null;
|
|
567
586
|
export function TESTING_ProcessBytestringArray(input: Buffer[]): Buffer[];
|
|
587
|
+
export function TESTING_RegistrationSessionInfoConvert(): RegistrationSession;
|
|
568
588
|
export function TESTING_ReturnStringArray(): string[];
|
|
569
589
|
export function TESTING_RoundTripI32(input: number): number;
|
|
570
590
|
export function TESTING_RoundTripU16(input: number): number;
|
|
@@ -650,6 +670,8 @@ interface ReceiptCredentialPresentation { readonly __type: unique symbol; }
|
|
|
650
670
|
interface ReceiptCredentialRequest { readonly __type: unique symbol; }
|
|
651
671
|
interface ReceiptCredentialRequestContext { readonly __type: unique symbol; }
|
|
652
672
|
interface ReceiptCredentialResponse { readonly __type: unique symbol; }
|
|
673
|
+
interface RegistrationService { readonly __type: unique symbol; }
|
|
674
|
+
interface RegistrationSession { readonly __type: unique symbol; }
|
|
653
675
|
interface SanitizedMetadata { readonly __type: unique symbol; }
|
|
654
676
|
interface SealedSenderDecryptionResult { readonly __type: unique symbol; }
|
|
655
677
|
interface SenderCertificate { readonly __type: unique symbol; }
|
package/dist/MessageBackup.js
CHANGED
|
@@ -85,9 +85,17 @@ var Purpose;
|
|
|
85
85
|
* @see OnlineBackupValidator
|
|
86
86
|
*/
|
|
87
87
|
async function validate(backupKey, purpose, inputFactory, length) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
let firstStream;
|
|
89
|
+
let secondStream;
|
|
90
|
+
try {
|
|
91
|
+
firstStream = inputFactory();
|
|
92
|
+
secondStream = inputFactory();
|
|
93
|
+
return new ValidationOutcome(await Native.MessageBackupValidator_Validate(backupKey, firstStream, secondStream, length, purpose));
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await firstStream?.close();
|
|
97
|
+
await secondStream?.close();
|
|
98
|
+
}
|
|
91
99
|
}
|
|
92
100
|
exports.validate = validate;
|
|
93
101
|
/**
|
package/dist/io.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ import type { Buffer } from 'node:buffer';
|
|
|
7
7
|
export declare abstract class InputStream implements Native.InputStream {
|
|
8
8
|
_read(amount: number): Promise<Buffer>;
|
|
9
9
|
_skip(amount: number): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Called to indicate the stream's resources should be released.
|
|
12
|
+
*
|
|
13
|
+
* The default implementation does nothing and completes immediately. Subclasses should not expect
|
|
14
|
+
*/
|
|
15
|
+
close(): Promise<void>;
|
|
10
16
|
/**
|
|
11
17
|
* Read an amount of bytes from the input stream.
|
|
12
18
|
*
|
package/dist/io.js
CHANGED
|
@@ -15,6 +15,14 @@ class InputStream {
|
|
|
15
15
|
_skip(amount) {
|
|
16
16
|
return this.skip(amount);
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Called to indicate the stream's resources should be released.
|
|
20
|
+
*
|
|
21
|
+
* The default implementation does nothing and completes immediately. Subclasses should not expect
|
|
22
|
+
*/
|
|
23
|
+
close() {
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
}
|
|
18
26
|
}
|
|
19
27
|
exports.InputStream = InputStream;
|
|
20
28
|
//# sourceMappingURL=io.js.map
|
package/dist/net/Chat.d.ts
CHANGED
|
@@ -86,6 +86,15 @@ export declare class UnauthenticatedChatConnection implements ChatConnection {
|
|
|
86
86
|
static connect(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, listener: ConnectionEventsListener, options?: {
|
|
87
87
|
abortSignal?: AbortSignal;
|
|
88
88
|
}): Promise<UnauthenticatedChatConnection>;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a chat connection backed by a fake remote end.
|
|
91
|
+
*
|
|
92
|
+
* @param asyncContext the async runtime to use
|
|
93
|
+
* @param listener the listener to send events to
|
|
94
|
+
* @returns an {@link UnauthenticatedChatConnection} and handle for the remote
|
|
95
|
+
* end of the fake connection.
|
|
96
|
+
*/
|
|
97
|
+
static fakeConnect(asyncContext: TokioAsyncContext, listener: ChatServiceListener): [UnauthenticatedChatConnection, Wrapper<Native.FakeChatRemoteEnd>];
|
|
89
98
|
private constructor();
|
|
90
99
|
fetch(chatRequest: ChatRequest, options?: {
|
|
91
100
|
abortSignal?: AbortSignal;
|
package/dist/net/Chat.js
CHANGED
|
@@ -49,6 +49,23 @@ class UnauthenticatedChatConnection {
|
|
|
49
49
|
Native.UnauthenticatedChatConnection_init_listener(connection, new WeakListenerWrapper(nativeChatListener));
|
|
50
50
|
return new UnauthenticatedChatConnection(asyncContext, connection, nativeChatListener);
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a chat connection backed by a fake remote end.
|
|
54
|
+
*
|
|
55
|
+
* @param asyncContext the async runtime to use
|
|
56
|
+
* @param listener the listener to send events to
|
|
57
|
+
* @returns an {@link UnauthenticatedChatConnection} and handle for the remote
|
|
58
|
+
* end of the fake connection.
|
|
59
|
+
*/
|
|
60
|
+
static fakeConnect(asyncContext, listener) {
|
|
61
|
+
const nativeChatListener = makeNativeChatListener(asyncContext, listener);
|
|
62
|
+
const fakeChat = (0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_Create(asyncContext, new WeakListenerWrapper(nativeChatListener), ''));
|
|
63
|
+
const chat = (0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_TakeUnauthenticatedChat(fakeChat));
|
|
64
|
+
return [
|
|
65
|
+
new UnauthenticatedChatConnection(asyncContext, chat, nativeChatListener),
|
|
66
|
+
(0, net_1.newNativeHandle)(Native.TESTING_FakeChatConnection_TakeRemote(fakeChat)),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
52
69
|
constructor(asyncContext, chatService,
|
|
53
70
|
// Unused except to keep the listener alive since the Rust code only holds a
|
|
54
71
|
// weak reference to the same object.
|
|
@@ -172,8 +189,10 @@ function makeNativeChatListener(asyncContext, listener) {
|
|
|
172
189
|
_queue_empty() {
|
|
173
190
|
throw new Error('Event not supported on unauthenticated connection');
|
|
174
191
|
},
|
|
175
|
-
_received_alerts(
|
|
176
|
-
|
|
192
|
+
_received_alerts(alerts) {
|
|
193
|
+
if (alerts.length != 0) {
|
|
194
|
+
throw new Error(`Got ${alerts.length} unexpected alerts on an unauthenticated connection`);
|
|
195
|
+
}
|
|
177
196
|
},
|
|
178
197
|
_connection_interrupted(cause) {
|
|
179
198
|
listener.onConnectionInterrupted(cause);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
2
|
+
import * as Native from '../../Native';
|
|
3
|
+
import { type TokioAsyncContext } from '../net';
|
|
4
|
+
type ConnectionManager = Native.Wrapper<Native.ConnectionManager>;
|
|
5
|
+
type RegistrationOptions = {
|
|
6
|
+
tokioAsyncContext: TokioAsyncContext;
|
|
7
|
+
connectionManager: ConnectionManager;
|
|
8
|
+
connectionTimeoutMillis?: number;
|
|
9
|
+
};
|
|
10
|
+
export type RegistrationSessionState = {
|
|
11
|
+
allowedToRequestCode: boolean;
|
|
12
|
+
verified: boolean;
|
|
13
|
+
nextSmsSecs?: number;
|
|
14
|
+
nextCallSecs?: number;
|
|
15
|
+
nextVerificationAttemptSecs?: number;
|
|
16
|
+
requestedInformation: Set<'pushChallenge' | 'captcha'>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A client for the Signal registration service.
|
|
20
|
+
*
|
|
21
|
+
* This wraps a {@link Net} to provide a reliable registration service client.
|
|
22
|
+
*/
|
|
23
|
+
export declare class RegistrationService {
|
|
24
|
+
readonly _nativeHandle: Native.RegistrationService;
|
|
25
|
+
private readonly tokioAsyncContext;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* The stable identifier for the session.
|
|
29
|
+
*
|
|
30
|
+
* This can be persisted and used later for resuming a session that was
|
|
31
|
+
* interrupted.
|
|
32
|
+
*/
|
|
33
|
+
get sessionId(): string;
|
|
34
|
+
/**
|
|
35
|
+
* The last known state of the session.
|
|
36
|
+
*
|
|
37
|
+
* The state received from the server is stored internally and is exposed via
|
|
38
|
+
* this property.
|
|
39
|
+
*/
|
|
40
|
+
get sessionState(): RegistrationSessionState;
|
|
41
|
+
/**
|
|
42
|
+
* Resumes a previously created registration session.
|
|
43
|
+
*
|
|
44
|
+
* Asynchronously connects to the registration session and verifies that the
|
|
45
|
+
* session is still available. If so, returns an initialized
|
|
46
|
+
* `RegistrationService`. Otherwise the returned `Promise` is resolved with an
|
|
47
|
+
* error.
|
|
48
|
+
*
|
|
49
|
+
* Clients should not use this method directly, but should instead call
|
|
50
|
+
* {@link Net.resumeRegistrationSession}.
|
|
51
|
+
*
|
|
52
|
+
* @returns a `Promise` that resolves to the `RegistrationService` if
|
|
53
|
+
* resumption is successful, otherwise a {@link LibSignalError}.
|
|
54
|
+
*/
|
|
55
|
+
static resumeSession(options: ReadonlyDeep<RegistrationOptions>, { sessionId }: {
|
|
56
|
+
sessionId: string;
|
|
57
|
+
}): Promise<RegistrationService>;
|
|
58
|
+
/**
|
|
59
|
+
* Starts a new registration session.
|
|
60
|
+
*
|
|
61
|
+
* Asynchronously connects to the registration session and requests a new session.
|
|
62
|
+
* If successful, returns an initialized `RegistrationService`. Otherwise the
|
|
63
|
+
* returned `Promise` is resolved with an error.
|
|
64
|
+
*
|
|
65
|
+
* Clients should not use this method directly, but should instead call
|
|
66
|
+
* {@link Net.createRegistrationSession}.
|
|
67
|
+
*
|
|
68
|
+
* @returns a `Promise` that resolves to the `RegistrationService` if
|
|
69
|
+
* creation is successful, otherwise a {@link RateLimitedError} or other
|
|
70
|
+
* {@link LibSignalError}.
|
|
71
|
+
*/
|
|
72
|
+
static createSession(options: ReadonlyDeep<RegistrationOptions>, { e164 }: {
|
|
73
|
+
e164: string;
|
|
74
|
+
}): Promise<RegistrationService>;
|
|
75
|
+
submitCaptcha(captcha: string): Promise<{
|
|
76
|
+
allowedToRequestCode: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
requestVerification({ transport, client, }: {
|
|
79
|
+
transport: 'sms' | 'voice';
|
|
80
|
+
client: string;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
verifySession(code: string): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* Internal, only public for testing
|
|
85
|
+
*/
|
|
86
|
+
static _convertNativeSessionState(session: Native.Wrapper<Native.RegistrationSession>): RegistrationSessionState;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//
|
|
3
|
+
// Copyright 2025 Signal Messenger, LLC.
|
|
4
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
//
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RegistrationService = void 0;
|
|
8
|
+
const Native = require("../../Native");
|
|
9
|
+
const net_1 = require("../net");
|
|
10
|
+
/**
|
|
11
|
+
* A client for the Signal registration service.
|
|
12
|
+
*
|
|
13
|
+
* This wraps a {@link Net} to provide a reliable registration service client.
|
|
14
|
+
*/
|
|
15
|
+
class RegistrationService {
|
|
16
|
+
constructor(_nativeHandle, tokioAsyncContext) {
|
|
17
|
+
this._nativeHandle = _nativeHandle;
|
|
18
|
+
this.tokioAsyncContext = tokioAsyncContext;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The stable identifier for the session.
|
|
22
|
+
*
|
|
23
|
+
* This can be persisted and used later for resuming a session that was
|
|
24
|
+
* interrupted.
|
|
25
|
+
*/
|
|
26
|
+
get sessionId() {
|
|
27
|
+
return Native.RegistrationService_SessionId(this);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The last known state of the session.
|
|
31
|
+
*
|
|
32
|
+
* The state received from the server is stored internally and is exposed via
|
|
33
|
+
* this property.
|
|
34
|
+
*/
|
|
35
|
+
get sessionState() {
|
|
36
|
+
return RegistrationService._convertNativeSessionState((0, net_1.newNativeHandle)(Native.RegistrationService_RegistrationSession(this)));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resumes a previously created registration session.
|
|
40
|
+
*
|
|
41
|
+
* Asynchronously connects to the registration session and verifies that the
|
|
42
|
+
* session is still available. If so, returns an initialized
|
|
43
|
+
* `RegistrationService`. Otherwise the returned `Promise` is resolved with an
|
|
44
|
+
* error.
|
|
45
|
+
*
|
|
46
|
+
* Clients should not use this method directly, but should instead call
|
|
47
|
+
* {@link Net.resumeRegistrationSession}.
|
|
48
|
+
*
|
|
49
|
+
* @returns a `Promise` that resolves to the `RegistrationService` if
|
|
50
|
+
* resumption is successful, otherwise a {@link LibSignalError}.
|
|
51
|
+
*/
|
|
52
|
+
static async resumeSession(options, { sessionId }) {
|
|
53
|
+
const session = await Native.RegistrationService_ResumeSession(options.tokioAsyncContext, sessionId, options.connectionManager);
|
|
54
|
+
return new RegistrationService(session, options.tokioAsyncContext);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Starts a new registration session.
|
|
58
|
+
*
|
|
59
|
+
* Asynchronously connects to the registration session and requests a new session.
|
|
60
|
+
* If successful, returns an initialized `RegistrationService`. Otherwise the
|
|
61
|
+
* returned `Promise` is resolved with an error.
|
|
62
|
+
*
|
|
63
|
+
* Clients should not use this method directly, but should instead call
|
|
64
|
+
* {@link Net.createRegistrationSession}.
|
|
65
|
+
*
|
|
66
|
+
* @returns a `Promise` that resolves to the `RegistrationService` if
|
|
67
|
+
* creation is successful, otherwise a {@link RateLimitedError} or other
|
|
68
|
+
* {@link LibSignalError}.
|
|
69
|
+
*/
|
|
70
|
+
static async createSession(options, { e164 }) {
|
|
71
|
+
const session = await Native.RegistrationService_CreateSession(options.tokioAsyncContext, { number: e164 }, options.connectionManager);
|
|
72
|
+
return new RegistrationService(session, options.tokioAsyncContext);
|
|
73
|
+
}
|
|
74
|
+
async submitCaptcha(captcha) {
|
|
75
|
+
await Native.RegistrationService_SubmitCaptcha(this.tokioAsyncContext, this, captcha);
|
|
76
|
+
return this.sessionState;
|
|
77
|
+
}
|
|
78
|
+
async requestVerification({ transport, client, }) {
|
|
79
|
+
await Native.RegistrationService_RequestVerificationCode(this.tokioAsyncContext, this, transport, client);
|
|
80
|
+
}
|
|
81
|
+
async verifySession(code) {
|
|
82
|
+
await Native.RegistrationService_SubmitVerificationCode(this.tokioAsyncContext, this, code);
|
|
83
|
+
return this.sessionState.verified;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Internal, only public for testing
|
|
87
|
+
*/
|
|
88
|
+
static _convertNativeSessionState(session) {
|
|
89
|
+
const nextCallSecs = Native.RegistrationSession_GetNextCallSeconds(session);
|
|
90
|
+
const nextSmsSecs = Native.RegistrationSession_GetNextSmsSeconds(session);
|
|
91
|
+
const nextVerificationAttemptSecs = Native.RegistrationSession_GetNextVerificationAttemptSeconds(session);
|
|
92
|
+
return {
|
|
93
|
+
allowedToRequestCode: Native.RegistrationSession_GetAllowedToRequestCode(session),
|
|
94
|
+
verified: Native.RegistrationSession_GetVerified(session),
|
|
95
|
+
nextCallSecs: nextCallSecs != null ? nextCallSecs : undefined,
|
|
96
|
+
nextSmsSecs: nextSmsSecs != null ? nextSmsSecs : undefined,
|
|
97
|
+
nextVerificationAttemptSecs: nextVerificationAttemptSecs != null
|
|
98
|
+
? nextVerificationAttemptSecs
|
|
99
|
+
: undefined,
|
|
100
|
+
requestedInformation: new Set(Native.RegistrationSession_GetRequestedInformation(session)),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.RegistrationService = RegistrationService;
|
|
105
|
+
//# sourceMappingURL=Registration.js.map
|
package/dist/net.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ import * as Native from '../Native';
|
|
|
4
4
|
import { Buffer } from 'node:buffer';
|
|
5
5
|
import { CDSRequestOptionsType, CDSResponseType } from './net/CDSI';
|
|
6
6
|
import { ConnectionEventsListener, UnauthenticatedChatConnection, AuthenticatedChatConnection, ChatServiceListener } from './net/Chat';
|
|
7
|
+
import { RegistrationService } from './net/Registration';
|
|
7
8
|
export * from './net/CDSI';
|
|
8
9
|
export * from './net/Chat';
|
|
10
|
+
export * from './net/Registration';
|
|
9
11
|
export declare enum Environment {
|
|
10
12
|
Staging = 0,
|
|
11
13
|
Production = 1
|
|
@@ -87,6 +89,14 @@ export declare class Net {
|
|
|
87
89
|
connectAuthenticatedChat(username: string, password: string, receiveStories: boolean, listener: ChatServiceListener, options?: {
|
|
88
90
|
abortSignal?: AbortSignal;
|
|
89
91
|
}): Promise<AuthenticatedChatConnection>;
|
|
92
|
+
resumeRegistrationSession({ sessionId, connectionTimeoutMillis, }: {
|
|
93
|
+
sessionId: string;
|
|
94
|
+
connectionTimeoutMillis?: number;
|
|
95
|
+
}): Promise<RegistrationService>;
|
|
96
|
+
createRegistrationSession({ e164, connectionTimeoutMillis, }: {
|
|
97
|
+
e164: string;
|
|
98
|
+
connectionTimeoutMillis?: number;
|
|
99
|
+
}): Promise<RegistrationService>;
|
|
90
100
|
/**
|
|
91
101
|
* Enables/disables IPv6 for all new connections (until changed).
|
|
92
102
|
*
|
package/dist/net.js
CHANGED
|
@@ -22,8 +22,10 @@ exports.Net = exports.SIGNAL_TLS_PROXY_SCHEME = exports.TokioAsyncContext = expo
|
|
|
22
22
|
const Native = require("../Native");
|
|
23
23
|
const CDSI_1 = require("./net/CDSI");
|
|
24
24
|
const Chat_1 = require("./net/Chat");
|
|
25
|
+
const Registration_1 = require("./net/Registration");
|
|
25
26
|
__exportStar(require("./net/CDSI"), exports);
|
|
26
27
|
__exportStar(require("./net/Chat"), exports);
|
|
28
|
+
__exportStar(require("./net/Registration"), exports);
|
|
27
29
|
// This must match the libsignal-bridge Rust enum of the same name.
|
|
28
30
|
var Environment;
|
|
29
31
|
(function (Environment) {
|
|
@@ -101,6 +103,20 @@ class Net {
|
|
|
101
103
|
connectAuthenticatedChat(username, password, receiveStories, listener, options) {
|
|
102
104
|
return Chat_1.AuthenticatedChatConnection.connect(this.asyncContext, this._connectionManager, username, password, receiveStories, listener, options);
|
|
103
105
|
}
|
|
106
|
+
async resumeRegistrationSession({ sessionId, connectionTimeoutMillis, }) {
|
|
107
|
+
return Registration_1.RegistrationService.resumeSession({
|
|
108
|
+
connectionManager: this._connectionManager,
|
|
109
|
+
tokioAsyncContext: this.asyncContext,
|
|
110
|
+
connectionTimeoutMillis: connectionTimeoutMillis,
|
|
111
|
+
}, { sessionId });
|
|
112
|
+
}
|
|
113
|
+
async createRegistrationSession({ e164, connectionTimeoutMillis, }) {
|
|
114
|
+
return Registration_1.RegistrationService.createSession({
|
|
115
|
+
connectionManager: this._connectionManager,
|
|
116
|
+
tokioAsyncContext: this.asyncContext,
|
|
117
|
+
connectionTimeoutMillis: connectionTimeoutMillis,
|
|
118
|
+
}, { e164 });
|
|
119
|
+
}
|
|
104
120
|
/**
|
|
105
121
|
* Enables/disables IPv6 for all new connections (until changed).
|
|
106
122
|
*
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|