@signalapp/libsignal-client 0.67.6 → 0.68.1

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 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;
@@ -567,6 +584,7 @@ export function TESTING_PanicOnReturnAsync(_needsCleanup: null): Promise<null>;
567
584
  export function TESTING_PanicOnReturnIo(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, _needsCleanup: null): CancellablePromise<null>;
568
585
  export function TESTING_PanicOnReturnSync(_needsCleanup: null): null;
569
586
  export function TESTING_ProcessBytestringArray(input: Buffer[]): Buffer[];
587
+ export function TESTING_RegistrationSessionInfoConvert(): RegistrationSession;
570
588
  export function TESTING_ReturnStringArray(): string[];
571
589
  export function TESTING_RoundTripI32(input: number): number;
572
590
  export function TESTING_RoundTripU16(input: number): number;
@@ -652,6 +670,8 @@ interface ReceiptCredentialPresentation { readonly __type: unique symbol; }
652
670
  interface ReceiptCredentialRequest { readonly __type: unique symbol; }
653
671
  interface ReceiptCredentialRequestContext { readonly __type: unique symbol; }
654
672
  interface ReceiptCredentialResponse { readonly __type: unique symbol; }
673
+ interface RegistrationService { readonly __type: unique symbol; }
674
+ interface RegistrationSession { readonly __type: unique symbol; }
655
675
  interface SanitizedMetadata { readonly __type: unique symbol; }
656
676
  interface SealedSenderDecryptionResult { readonly __type: unique symbol; }
657
677
  interface SenderCertificate { readonly __type: unique symbol; }
@@ -85,9 +85,17 @@ var Purpose;
85
85
  * @see OnlineBackupValidator
86
86
  */
87
87
  async function validate(backupKey, purpose, inputFactory, length) {
88
- const firstStream = inputFactory();
89
- const secondStream = inputFactory();
90
- return new ValidationOutcome(await Native.MessageBackupValidator_Validate(backupKey, firstStream, secondStream, length, purpose));
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
  /**
@@ -3338,7 +3338,7 @@ THE SOFTWARE.
3338
3338
 
3339
3339
  ```
3340
3340
 
3341
- ## either 1.15.0, itertools 0.10.5, itertools 0.14.0, petgraph 0.7.1
3341
+ ## either 1.15.0, itertools 0.10.5, itertools 0.14.0, petgraph 0.7.1, serde_with 3.12.0, serde_with_macros 3.12.0
3342
3342
 
3343
3343
  ```
3344
3344
  Copyright (c) 2015
@@ -3481,7 +3481,7 @@ DEALINGS IN THE SOFTWARE.
3481
3481
 
3482
3482
  ```
3483
3483
 
3484
- ## gimli 0.31.1, heck 0.5.0
3484
+ ## gimli 0.31.1, heck 0.5.0, unicode-xid 0.2.6
3485
3485
 
3486
3486
  ```
3487
3487
  Copyright (c) 2015 The Rust Project Developers
@@ -4713,38 +4713,6 @@ DEALINGS IN THE SOFTWARE.
4713
4713
 
4714
4714
  ```
4715
4715
 
4716
- ## hex-literal 0.4.1
4717
-
4718
- ```
4719
- Copyright (c) 2018 Artyom Pavlov
4720
- Copyright (c) 2018 The RustCrypto Project Developers
4721
-
4722
- Permission is hereby granted, free of charge, to any
4723
- person obtaining a copy of this software and associated
4724
- documentation files (the "Software"), to deal in the
4725
- Software without restriction, including without
4726
- limitation the rights to use, copy, modify, merge,
4727
- publish, distribute, sublicense, and/or sell copies of
4728
- the Software, and to permit persons to whom the Software
4729
- is furnished to do so, subject to the following
4730
- conditions:
4731
-
4732
- The above copyright notice and this permission notice
4733
- shall be included in all copies or substantial portions
4734
- of the Software.
4735
-
4736
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
4737
- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
4738
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
4739
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
4740
- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
4741
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
4742
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
4743
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
4744
- DEALINGS IN THE SOFTWARE.
4745
-
4746
- ```
4747
-
4748
4716
  ## bytes 1.10.1
4749
4717
 
4750
4718
  ```
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.67.6",
3
+ "version": "0.68.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",