@signalapp/libsignal-client 0.70.1 → 0.71.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
@@ -57,10 +57,16 @@ type SealedSenderMultiRecipientMessage = {
57
57
  offsetOfSharedData: number;
58
58
  };
59
59
 
60
+ enum IdentityChange {
61
+ // This must be kept in sync with the Rust enum of the same name.
62
+ NewOrUnchanged = 0,
63
+ ReplacedExisting = 1,
64
+ }
65
+
60
66
  type IdentityKeyStore = {
61
67
  _getIdentityKey(): Promise<PrivateKey>;
62
68
  _getLocalRegistrationId(): Promise<number>;
63
- _saveIdentity(name: ProtocolAddress, key: PublicKey): Promise<boolean>;
69
+ _saveIdentity(name: ProtocolAddress, key: PublicKey): Promise<IdentityChange>;
64
70
  _isTrustedIdentity(
65
71
  name: ProtocolAddress,
66
72
  key: PublicKey,
@@ -148,6 +154,11 @@ type RegisterResponseBadge = {
148
154
  expirationSeconds: number;
149
155
  };
150
156
 
157
+ type CheckSvr2CredentialsResponse = Map<
158
+ string,
159
+ 'match' | 'no-match' | 'invalid'
160
+ >;
161
+
151
162
  type SignedPublicPreKey = {
152
163
  keyId: number;
153
164
  publicKey: Buffer;
@@ -334,6 +345,12 @@ export function IncrementalMac_CalculateChunkSize(dataSize: number): number;
334
345
  export function IncrementalMac_Finalize(mac: Wrapper<IncrementalMac>): Buffer;
335
346
  export function IncrementalMac_Initialize(key: Buffer, chunkSize: number): IncrementalMac;
336
347
  export function IncrementalMac_Update(mac: Wrapper<IncrementalMac>, bytes: Buffer, offset: number, length: number): Buffer;
348
+ export function KeyTransparency_AciSearchKey(aci: Buffer): Buffer;
349
+ export function KeyTransparency_Distinguished(asyncRuntime: Wrapper<TokioAsyncContext>, environment: number, chatConnection: Wrapper<UnauthenticatedChatConnection>, lastDistinguishedTreeHead: Buffer | null): CancellablePromise<Buffer>;
350
+ export function KeyTransparency_E164SearchKey(e164: string): Buffer;
351
+ export function KeyTransparency_Monitor(asyncRuntime: Wrapper<TokioAsyncContext>, environment: number, chatConnection: Wrapper<UnauthenticatedChatConnection>, aci: Buffer, aciIdentityKey: Wrapper<PublicKey>, e164: string | null, unidentifiedAccessKey: Buffer | null, usernameHash: Buffer | null, accountData: Buffer | null, lastDistinguishedTreeHead: Buffer): CancellablePromise<Buffer>;
352
+ export function KeyTransparency_Search(asyncRuntime: Wrapper<TokioAsyncContext>, environment: number, chatConnection: Wrapper<UnauthenticatedChatConnection>, aci: Buffer, aciIdentityKey: Wrapper<PublicKey>, e164: string | null, unidentifiedAccessKey: Buffer | null, usernameHash: Buffer | null, accountData: Buffer | null, lastDistinguishedTreeHead: Buffer): CancellablePromise<SearchResult>;
353
+ export function KeyTransparency_UsernameHashSearchKey(hash: Buffer): Buffer;
337
354
  export function KyberKeyPair_Generate(): KyberKeyPair;
338
355
  export function KyberKeyPair_GetPublicKey(keyPair: Wrapper<KyberKeyPair>): KyberPublicKey;
339
356
  export function KyberKeyPair_GetSecretKey(keyPair: Wrapper<KyberKeyPair>): KyberSecretKey;
@@ -434,7 +451,7 @@ export function ReceiptCredential_CheckValidContents(buffer: Buffer): void;
434
451
  export function ReceiptCredential_GetReceiptExpirationTime(receiptCredential: Serialized<ReceiptCredential>): Timestamp;
435
452
  export function ReceiptCredential_GetReceiptLevel(receiptCredential: Serialized<ReceiptCredential>): bigint;
436
453
  export function RegisterAccountRequest_Create(): RegisterAccountRequest;
437
- export function RegisterAccountRequest_SetAccountPassword(registerAccount: Wrapper<RegisterAccountRequest>, accountPassword: Buffer): void;
454
+ export function RegisterAccountRequest_SetAccountPassword(registerAccount: Wrapper<RegisterAccountRequest>, accountPassword: string): void;
438
455
  export function RegisterAccountRequest_SetIdentityPqLastResortPreKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, pqLastResortPreKey: SignedPublicPreKey): void;
439
456
  export function RegisterAccountRequest_SetIdentityPublicKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, identityKey: Wrapper<PublicKey>): void;
440
457
  export function RegisterAccountRequest_SetIdentitySignedPreKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, signedPreKey: SignedPublicPreKey): void;
@@ -449,6 +466,7 @@ export function RegisterAccountResponse_GetStorageCapable(response: Wrapper<Regi
449
466
  export function RegisterAccountResponse_GetUsernameHash(response: Wrapper<RegisterAccountResponse>): Buffer | null;
450
467
  export function RegisterAccountResponse_GetUsernameLinkHandle(response: Wrapper<RegisterAccountResponse>): Uuid | null;
451
468
  export function RegistrationAccountAttributes_Create(recoveryPassword: Buffer, aciRegistrationId: number, pniRegistrationId: number, registrationLock: string | null, unidentifiedAccessKey: Buffer | null, unrestrictedUnidentifiedAccess: boolean, capabilities: string[], discoverableByPhoneNumber: boolean): RegistrationAccountAttributes;
469
+ export function RegistrationService_CheckSvr2Credentials(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, svrTokens: string[]): CancellablePromise<CheckSvr2CredentialsResponse>;
452
470
  export function RegistrationService_CreateSession(asyncRuntime: Wrapper<TokioAsyncContext>, createSession: RegistrationCreateSessionRequest, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
453
471
  export function RegistrationService_RegisterAccount(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, registerAccount: Wrapper<RegisterAccountRequest>, accountAttributes: Wrapper<RegistrationAccountAttributes>): CancellablePromise<RegisterAccountResponse>;
454
472
  export function RegistrationService_RegistrationSession(service: Wrapper<RegistrationService>): RegistrationSession;
@@ -479,6 +497,11 @@ export function SealedSender_DecryptToUsmc(ctext: Buffer, identityStore: Identit
479
497
  export function SealedSender_Encrypt(destination: Wrapper<ProtocolAddress>, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Buffer>;
480
498
  export function SealedSender_MultiRecipientEncrypt(recipients: Wrapper<ProtocolAddress>[], recipientSessions: Wrapper<SessionRecord>[], excludedRecipients: Buffer, content: Wrapper<UnidentifiedSenderMessageContent>, identityKeyStore: IdentityKeyStore): Promise<Buffer>;
481
499
  export function SealedSender_MultiRecipientMessageForSingleRecipient(encodedMultiRecipientMessage: Buffer): Buffer;
500
+ export function SearchResult_GetAccountData(res: Wrapper<SearchResult>): Buffer;
501
+ export function SearchResult_GetAciForE164(res: Wrapper<SearchResult>): Buffer | null;
502
+ export function SearchResult_GetAciForUsernameHash(res: Wrapper<SearchResult>): Buffer | null;
503
+ export function SearchResult_GetAciIdentityKey(res: Wrapper<SearchResult>): PublicKey;
504
+ export function SearchResult_GetTimestamp(res: Wrapper<SearchResult>): bigint;
482
505
  export function SenderCertificate_Deserialize(data: Buffer): SenderCertificate;
483
506
  export function SenderCertificate_GetCertificate(obj: Wrapper<SenderCertificate>): Buffer;
484
507
  export function SenderCertificate_GetDeviceId(obj: Wrapper<SenderCertificate>): number;
@@ -634,7 +657,10 @@ export function TESTING_PanicOnReturnIo(asyncRuntime: Wrapper<NonSuspendingBackg
634
657
  export function TESTING_PanicOnReturnSync(_needsCleanup: null): null;
635
658
  export function TESTING_ProcessBytestringArray(input: Buffer[]): Buffer[];
636
659
  export function TESTING_RegisterAccountResponse_CreateTestValue(): RegisterAccountResponse;
660
+ export function TESTING_RegistrationService_CheckSvr2CredentialsErrorConvert(errorDescription: string): void;
661
+ export function TESTING_RegistrationService_CheckSvr2CredentialsResponseConvert(): CheckSvr2CredentialsResponse;
637
662
  export function TESTING_RegistrationService_CreateSessionErrorConvert(errorDescription: string): void;
663
+ export function TESTING_RegistrationService_RegisterAccountErrorConvert(errorDescription: string): void;
638
664
  export function TESTING_RegistrationService_RequestVerificationCodeErrorConvert(errorDescription: string): void;
639
665
  export function TESTING_RegistrationService_ResumeSessionErrorConvert(errorDescription: string): void;
640
666
  export function TESTING_RegistrationService_SubmitVerificationErrorConvert(errorDescription: string): void;
@@ -736,6 +762,7 @@ interface RegistrationService { readonly __type: unique symbol; }
736
762
  interface RegistrationSession { readonly __type: unique symbol; }
737
763
  interface SanitizedMetadata { readonly __type: unique symbol; }
738
764
  interface SealedSenderDecryptionResult { readonly __type: unique symbol; }
765
+ interface SearchResult { readonly __type: unique symbol; }
739
766
  interface SenderCertificate { readonly __type: unique symbol; }
740
767
  interface SenderKeyDistributionMessage { readonly __type: unique symbol; }
741
768
  interface SenderKeyMessage { readonly __type: unique symbol; }
@@ -2708,133 +2708,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2708
2708
 
2709
2709
  ```
2710
2710
 
2711
- ## dunce 1.0.5
2712
-
2713
- ```
2714
- Creative Commons Legal Code
2715
-
2716
- CC0 1.0 Universal
2717
-
2718
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
2719
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
2720
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
2721
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
2722
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
2723
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
2724
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
2725
- HEREUNDER.
2726
-
2727
- Statement of Purpose
2728
-
2729
- The laws of most jurisdictions throughout the world automatically confer
2730
- exclusive Copyright and Related Rights (defined below) upon the creator
2731
- and subsequent owner(s) (each and all, an "owner") of an original work of
2732
- authorship and/or a database (each, a "Work").
2733
-
2734
- Certain owners wish to permanently relinquish those rights to a Work for
2735
- the purpose of contributing to a commons of creative, cultural and
2736
- scientific works ("Commons") that the public can reliably and without fear
2737
- of later claims of infringement build upon, modify, incorporate in other
2738
- works, reuse and redistribute as freely as possible in any form whatsoever
2739
- and for any purposes, including without limitation commercial purposes.
2740
- These owners may contribute to the Commons to promote the ideal of a free
2741
- culture and the further production of creative, cultural and scientific
2742
- works, or to gain reputation or greater distribution for their Work in
2743
- part through the use and efforts of others.
2744
-
2745
- For these and/or other purposes and motivations, and without any
2746
- expectation of additional consideration or compensation, the person
2747
- associating CC0 with a Work (the "Affirmer"), to the extent that he or she
2748
- is an owner of Copyright and Related Rights in the Work, voluntarily
2749
- elects to apply CC0 to the Work and publicly distribute the Work under its
2750
- terms, with knowledge of his or her Copyright and Related Rights in the
2751
- Work and the meaning and intended legal effect of CC0 on those rights.
2752
-
2753
- 1. Copyright and Related Rights. A Work made available under CC0 may be
2754
- protected by copyright and related or neighboring rights ("Copyright and
2755
- Related Rights"). Copyright and Related Rights include, but are not
2756
- limited to, the following:
2757
-
2758
- i. the right to reproduce, adapt, distribute, perform, display,
2759
- communicate, and translate a Work;
2760
- ii. moral rights retained by the original author(s) and/or performer(s);
2761
- iii. publicity and privacy rights pertaining to a person's image or
2762
- likeness depicted in a Work;
2763
- iv. rights protecting against unfair competition in regards to a Work,
2764
- subject to the limitations in paragraph 4(a), below;
2765
- v. rights protecting the extraction, dissemination, use and reuse of data
2766
- in a Work;
2767
- vi. database rights (such as those arising under Directive 96/9/EC of the
2768
- European Parliament and of the Council of 11 March 1996 on the legal
2769
- protection of databases, and under any national implementation
2770
- thereof, including any amended or successor version of such
2771
- directive); and
2772
- vii. other similar, equivalent or corresponding rights throughout the
2773
- world based on applicable law or treaty, and any national
2774
- implementations thereof.
2775
-
2776
- 2. Waiver. To the greatest extent permitted by, but not in contravention
2777
- of, applicable law, Affirmer hereby overtly, fully, permanently,
2778
- irrevocably and unconditionally waives, abandons, and surrenders all of
2779
- Affirmer's Copyright and Related Rights and associated claims and causes
2780
- of action, whether now known or unknown (including existing as well as
2781
- future claims and causes of action), in the Work (i) in all territories
2782
- worldwide, (ii) for the maximum duration provided by applicable law or
2783
- treaty (including future time extensions), (iii) in any current or future
2784
- medium and for any number of copies, and (iv) for any purpose whatsoever,
2785
- including without limitation commercial, advertising or promotional
2786
- purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
2787
- member of the public at large and to the detriment of Affirmer's heirs and
2788
- successors, fully intending that such Waiver shall not be subject to
2789
- revocation, rescission, cancellation, termination, or any other legal or
2790
- equitable action to disrupt the quiet enjoyment of the Work by the public
2791
- as contemplated by Affirmer's express Statement of Purpose.
2792
-
2793
- 3. Public License Fallback. Should any part of the Waiver for any reason
2794
- be judged legally invalid or ineffective under applicable law, then the
2795
- Waiver shall be preserved to the maximum extent permitted taking into
2796
- account Affirmer's express Statement of Purpose. In addition, to the
2797
- extent the Waiver is so judged Affirmer hereby grants to each affected
2798
- person a royalty-free, non transferable, non sublicensable, non exclusive,
2799
- irrevocable and unconditional license to exercise Affirmer's Copyright and
2800
- Related Rights in the Work (i) in all territories worldwide, (ii) for the
2801
- maximum duration provided by applicable law or treaty (including future
2802
- time extensions), (iii) in any current or future medium and for any number
2803
- of copies, and (iv) for any purpose whatsoever, including without
2804
- limitation commercial, advertising or promotional purposes (the
2805
- "License"). The License shall be deemed effective as of the date CC0 was
2806
- applied by Affirmer to the Work. Should any part of the License for any
2807
- reason be judged legally invalid or ineffective under applicable law, such
2808
- partial invalidity or ineffectiveness shall not invalidate the remainder
2809
- of the License, and in such case Affirmer hereby affirms that he or she
2810
- will not (i) exercise any of his or her remaining Copyright and Related
2811
- Rights in the Work or (ii) assert any associated claims and causes of
2812
- action with respect to the Work, in either case contrary to Affirmer's
2813
- express Statement of Purpose.
2814
-
2815
- 4. Limitations and Disclaimers.
2816
-
2817
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
2818
- surrendered, licensed or otherwise affected by this document.
2819
- b. Affirmer offers the Work as-is and makes no representations or
2820
- warranties of any kind concerning the Work, express, implied,
2821
- statutory or otherwise, including without limitation warranties of
2822
- title, merchantability, fitness for a particular purpose, non
2823
- infringement, or the absence of latent or other defects, accuracy, or
2824
- the present or absence of errors, whether or not discoverable, all to
2825
- the greatest extent permissible under applicable law.
2826
- c. Affirmer disclaims responsibility for clearing rights of other persons
2827
- that may apply to the Work or any use thereof, including without
2828
- limitation any person's Copyright and Related Rights in the Work.
2829
- Further, Affirmer disclaims responsibility for obtaining any necessary
2830
- consents, permissions or other rights required for any use of the
2831
- Work.
2832
- d. Affirmer understands and acknowledges that Creative Commons is not a
2833
- party to this document and has no duty or obligation with respect to
2834
- this CC0 or use of the Work.
2835
-
2836
- ```
2837
-
2838
2711
  ## boring-sys 4.15.0
2839
2712
 
2840
2713
  ```
@@ -3175,7 +3048,7 @@ DEALINGS IN THE SOFTWARE.
3175
3048
 
3176
3049
  ```
3177
3050
 
3178
- ## backtrace 0.3.74, cc 1.2.18, cfg-if 1.0.0, cmake 0.1.48, jobserver 0.1.33, openssl-probe 0.1.6, pkg-config 0.3.32, rustc-demangle 0.1.24, scoped-tls 1.0.1, socket2 0.5.9
3051
+ ## backtrace 0.3.74, cc 1.2.18, cfg-if 1.0.0, cmake 0.1.48, openssl-probe 0.1.6, pkg-config 0.3.32, rustc-demangle 0.1.24, scoped-tls 1.0.1, socket2 0.5.9
3179
3052
 
3180
3053
  ```
3181
3054
  Copyright (c) 2014 Alex Crichton
@@ -7222,7 +7095,7 @@ SOFTWARE.
7222
7095
 
7223
7096
  ```
7224
7097
 
7225
- ## cesu8 1.1.0, pqcrypto-internals 0.2.10, pqcrypto-kyber 0.7.9, pqcrypto-kyber 0.8.1, pqcrypto-traits 0.3.5
7098
+ ## cesu8 1.1.0
7226
7099
 
7227
7100
  ```
7228
7101
  MIT License
package/dist/index.d.ts CHANGED
@@ -268,15 +268,19 @@ export declare abstract class SessionStore implements Native.SessionStore {
268
268
  abstract getSession(name: ProtocolAddress): Promise<SessionRecord | null>;
269
269
  abstract getExistingSessions(addresses: ProtocolAddress[]): Promise<SessionRecord[]>;
270
270
  }
271
+ export declare enum IdentityChange {
272
+ NewOrUnchanged = 0,
273
+ ReplacedExisting = 1
274
+ }
271
275
  export declare abstract class IdentityKeyStore implements Native.IdentityKeyStore {
272
276
  _getIdentityKey(): Promise<Native.PrivateKey>;
273
277
  _getLocalRegistrationId(): Promise<number>;
274
- _saveIdentity(name: Native.ProtocolAddress, key: Native.PublicKey): Promise<boolean>;
278
+ _saveIdentity(name: Native.ProtocolAddress, key: Native.PublicKey): Promise<Native.IdentityChange>;
275
279
  _isTrustedIdentity(name: Native.ProtocolAddress, key: Native.PublicKey, sending: boolean): Promise<boolean>;
276
280
  _getIdentity(name: Native.ProtocolAddress): Promise<Native.PublicKey | null>;
277
281
  abstract getIdentityKey(): Promise<PrivateKey>;
278
282
  abstract getLocalRegistrationId(): Promise<number>;
279
- abstract saveIdentity(name: ProtocolAddress, key: PublicKey): Promise<boolean>;
283
+ abstract saveIdentity(name: ProtocolAddress, key: PublicKey): Promise<IdentityChange>;
280
284
  abstract isTrustedIdentity(name: ProtocolAddress, key: PublicKey, direction: Direction): Promise<boolean>;
281
285
  abstract getIdentity(name: ProtocolAddress): Promise<PublicKey | null>;
282
286
  }
package/dist/index.js CHANGED
@@ -18,8 +18,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.sealedSenderMultiRecipientMessageForSingleRecipient = exports.sealedSenderMultiRecipientEncrypt = exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.KyberPreKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.KyberPreKeyRecord = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.KEMKeyPair = exports.KEMSecretKey = exports.KEMPublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.WebpSanitizer = exports.Mp4Sanitizer = exports.Net = exports.io = exports.usernames = void 0;
22
- exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = void 0;
21
+ exports.sealedSenderMultiRecipientEncrypt = exports.sealedSenderEncrypt = exports.sealedSenderEncryptMessage = exports.signalDecryptPreKey = exports.signalDecrypt = exports.signalEncrypt = exports.processPreKeyBundle = exports.DecryptionErrorMessage = exports.PlaintextContent = exports.CiphertextMessage = exports.SealedSenderDecryptionResult = exports.groupDecrypt = exports.groupEncrypt = exports.SenderKeyStore = exports.KyberPreKeyStore = exports.SignedPreKeyStore = exports.PreKeyStore = exports.IdentityKeyStore = exports.IdentityChange = exports.SessionStore = exports.UnidentifiedSenderMessageContent = exports.SenderKeyMessage = exports.processSenderKeyDistributionMessage = exports.SenderKeyDistributionMessage = exports.SenderCertificate = exports.SenderKeyRecord = exports.ServerCertificate = exports.SessionRecord = exports.PreKeySignalMessage = exports.SignalMessage = exports.KyberPreKeyRecord = exports.SignedPreKeyRecord = exports.PreKeyRecord = exports.PreKeyBundle = exports.KEMKeyPair = exports.KEMSecretKey = exports.KEMPublicKey = exports.Aes256GcmSiv = exports.Fingerprint = exports.DisplayableFingerprint = exports.ScannableFingerprint = exports.hkdf = exports.ContentHint = exports.Direction = exports.CiphertextMessageType = exports.WebpSanitizer = exports.Mp4Sanitizer = exports.Net = exports.io = exports.usernames = void 0;
22
+ exports.initLogger = exports.LogLevel = exports.HsmEnclaveClient = exports.Cds2Client = exports.sealedSenderDecryptToUsmc = exports.sealedSenderDecryptMessage = exports.sealedSenderMultiRecipientMessageForSingleRecipient = void 0;
23
23
  const uuid = require("uuid");
24
24
  const Errors = require("./Errors");
25
25
  __exportStar(require("./Errors"), exports);
@@ -619,6 +619,12 @@ class SessionStore {
619
619
  }
620
620
  }
621
621
  exports.SessionStore = SessionStore;
622
+ var IdentityChange;
623
+ (function (IdentityChange) {
624
+ // This must be kept in sync with the Rust enum of the same name.
625
+ IdentityChange[IdentityChange["NewOrUnchanged"] = 0] = "NewOrUnchanged";
626
+ IdentityChange[IdentityChange["ReplacedExisting"] = 1] = "ReplacedExisting";
627
+ })(IdentityChange || (exports.IdentityChange = IdentityChange = {}));
622
628
  class IdentityKeyStore {
623
629
  async _getIdentityKey() {
624
630
  const key = await this.getIdentityKey();
@@ -3,7 +3,8 @@ import * as Native from '../../Native';
3
3
  import { LibSignalError } from '../Errors';
4
4
  import { Wrapper } from '../../Native';
5
5
  import { Buffer } from 'node:buffer';
6
- import { TokioAsyncContext } from '../net';
6
+ import { TokioAsyncContext, Environment } from '../net';
7
+ import * as KT from './KeyTransparency';
7
8
  export type ChatRequest = Readonly<{
8
9
  verb: string;
9
10
  path: string;
@@ -11,7 +12,7 @@ export type ChatRequest = Readonly<{
11
12
  body?: Uint8Array;
12
13
  timeoutMillis?: number;
13
14
  }>;
14
- type ConnectionManager = Wrapper<Native.ConnectionManager>;
15
+ type ConnectionManager = Native.Wrapper<Native.ConnectionManager>;
15
16
  export declare class ChatServerMessageAck {
16
17
  readonly _nativeHandle: Native.ServerMessageAck;
17
18
  constructor(_nativeHandle: Native.ServerMessageAck);
@@ -83,7 +84,8 @@ export declare class UnauthenticatedChatConnection implements ChatConnection {
83
84
  private readonly asyncContext;
84
85
  private readonly chatService;
85
86
  private readonly chatListener;
86
- static connect(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, listener: ConnectionEventsListener, options?: {
87
+ private readonly env?;
88
+ static connect(asyncContext: TokioAsyncContext, connectionManager: ConnectionManager, listener: ConnectionEventsListener, env?: Environment, options?: {
87
89
  abortSignal?: AbortSignal;
88
90
  }): Promise<UnauthenticatedChatConnection>;
89
91
  /**
@@ -101,6 +103,7 @@ export declare class UnauthenticatedChatConnection implements ChatConnection {
101
103
  }): Promise<Native.ChatResponse>;
102
104
  disconnect(): Promise<void>;
103
105
  connectionInfo(): ConnectionInfo;
106
+ keyTransparencyClient(): KT.Client;
104
107
  }
105
108
  export declare class AuthenticatedChatConnection implements ChatConnection {
106
109
  private readonly asyncContext;
package/dist/net/Chat.js CHANGED
@@ -8,6 +8,7 @@ exports.buildHttpRequest = exports.AuthenticatedChatConnection = exports.Unauthe
8
8
  const Native = require("../../Native");
9
9
  const node_buffer_1 = require("node:buffer");
10
10
  const net_1 = require("../net");
11
+ const KT = require("./KeyTransparency");
11
12
  const DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS = 5000;
12
13
  class ChatServerMessageAck {
13
14
  constructor(_nativeHandle) {
@@ -41,13 +42,13 @@ class ConnectionInfoImpl {
41
42
  }
42
43
  }
43
44
  class UnauthenticatedChatConnection {
44
- static async connect(asyncContext, connectionManager, listener, options) {
45
+ static async connect(asyncContext, connectionManager, listener, env, options) {
45
46
  const nativeChatListener = makeNativeChatListener(asyncContext, listener);
46
47
  const connect = Native.UnauthenticatedChatConnection_connect(asyncContext, connectionManager);
47
48
  const chat = await asyncContext.makeCancellable(options?.abortSignal, connect);
48
49
  const connection = (0, net_1.newNativeHandle)(chat);
49
50
  Native.UnauthenticatedChatConnection_init_listener(connection, new WeakListenerWrapper(nativeChatListener));
50
- return new UnauthenticatedChatConnection(asyncContext, connection, nativeChatListener);
51
+ return new UnauthenticatedChatConnection(asyncContext, connection, nativeChatListener, env);
51
52
  }
52
53
  /**
53
54
  * Creates a chat connection backed by a fake remote end.
@@ -69,10 +70,11 @@ class UnauthenticatedChatConnection {
69
70
  constructor(asyncContext, chatService,
70
71
  // Unused except to keep the listener alive since the Rust code only holds a
71
72
  // weak reference to the same object.
72
- chatListener) {
73
+ chatListener, env) {
73
74
  this.asyncContext = asyncContext;
74
75
  this.chatService = chatService;
75
76
  this.chatListener = chatListener;
77
+ this.env = env;
76
78
  }
77
79
  fetch(chatRequest, options) {
78
80
  return this.asyncContext.makeCancellable(options?.abortSignal, Native.UnauthenticatedChatConnection_send(this.asyncContext, this.chatService, buildHttpRequest(chatRequest), chatRequest.timeoutMillis ?? DEFAULT_CHAT_REQUEST_TIMEOUT_MILLIS));
@@ -83,6 +85,12 @@ class UnauthenticatedChatConnection {
83
85
  connectionInfo() {
84
86
  return new ConnectionInfoImpl(Native.UnauthenticatedChatConnection_info(this.chatService));
85
87
  }
88
+ keyTransparencyClient() {
89
+ if (this.env == null) {
90
+ throw new Error('KeyTransparency is not supported on local test server');
91
+ }
92
+ return new KT.ClientImpl(this.asyncContext, this.chatService, this.env);
93
+ }
86
94
  }
87
95
  exports.UnauthenticatedChatConnection = UnauthenticatedChatConnection;
88
96
  class AuthenticatedChatConnection {
@@ -0,0 +1,129 @@
1
+ /// <reference types="node" />
2
+ import * as Native from '../../Native';
3
+ import { Aci } from '../Address';
4
+ import { PublicKey } from '../EcKeys';
5
+ import { Environment, type TokioAsyncContext } from '../net';
6
+ /**
7
+ * Interface of a local persistent key transparency data store.
8
+ *
9
+ * Contents of the store are opaque to the client and are only supposed to be
10
+ * used by the {@link Client}.
11
+ */
12
+ export interface Store {
13
+ getLastDistinguishedTreeHead(): Promise<Buffer | null>;
14
+ setLastDistinguishedTreeHead(bytes: Readonly<Buffer> | null): Promise<void>;
15
+ getAccountData(aci: Aci): Promise<Buffer | null>;
16
+ setAccountData(aci: Aci, bytes: Readonly<Buffer>): Promise<void>;
17
+ }
18
+ /**
19
+ * Options that are accepted by all {@link Client} APIs.
20
+ *
21
+ * abortSignal, if present, can be used to cancel long-running network IO.
22
+ */
23
+ export type Options = {
24
+ abortSignal?: AbortSignal;
25
+ };
26
+ /**
27
+ * ACI descriptor for key transparency requests.
28
+ */
29
+ export type AciInfo = {
30
+ aci: Aci;
31
+ identityKey: PublicKey;
32
+ };
33
+ /**
34
+ * E.164 descriptor for key transparency requests.
35
+ */
36
+ export type E164Info = {
37
+ e164: string;
38
+ unidentifiedAccessKey: Readonly<Buffer>;
39
+ };
40
+ /**
41
+ * Key transparency client request
42
+ *
43
+ */
44
+ export type Request = {
45
+ /** ACI and ACI Identity Key for the account. Required. */
46
+ aciInfo: AciInfo;
47
+ /** Unidentified access key associated with the account. Optional. */
48
+ e164Info?: E164Info;
49
+ usernameHash?: Readonly<Buffer>;
50
+ };
51
+ /**
52
+ * Typed API to access the key transparency subsystem using an existing
53
+ * unauthenticated chat connection.
54
+ *
55
+ * Unlike {@link UnauthenticatedChatConnection}, the client does
56
+ * not export "raw" send/receive APIs, and instead uses them internally to
57
+ * implement high-level key transparency operations.
58
+ *
59
+ * See {@link ClientImpl} for the implementation details.
60
+ *
61
+ * Instances should be obtained by calling {@link UnauthenticatedChatConnection.keyTransparencyClient}
62
+ *
63
+ * Example usage:
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const network = new Net({
68
+ * localTestServer: false,
69
+ * env: Environment.Staging,
70
+ * userAgent: 'key-transparency-example'
71
+ * });
72
+ *
73
+ * const chat = await network.connectUnauthenticatedChat({
74
+ * onConnectionInterrupted: (_cause) => {}
75
+ * });
76
+ *
77
+ * const kt = chat.keyTransparencyClient();
78
+ *
79
+ * // Promise fulfillment means the operation succeeded with no further steps required.
80
+ * await kt.search({ aciInfo: { aci: myACI, identityKey: myAciIdentityKey } }, store);
81
+ * ```
82
+ *
83
+ */
84
+ export interface Client {
85
+ /**
86
+ * Search for account information in the key transparency tree.
87
+ *
88
+ *
89
+ * @param request - Key transparency client {@link Request}.
90
+ * @param store - Local key transparency storage. It will be queried for both
91
+ * the account data and the latest distinguished tree head before sending the
92
+ * server request and, if the request succeeds, will be updated with the
93
+ * search operation results.
94
+ * @param options - options for the asynchronous operation. Optional.
95
+ *
96
+ * @returns A promise that resolves if the search succeeds and the local state has been updated
97
+ * to reflect the latest changes. If the promise is rejected, the UI should be updated to notify
98
+ * the user of the failure.
99
+ */
100
+ search(request: Request, store: Store, options?: Readonly<Options>): Promise<void>;
101
+ /**
102
+ * Perform a monitor operation for an account previously searched for.
103
+ *
104
+ * If the monitor request discovers that the client has changed their username
105
+ * or phone number, the search request will be performed instead.
106
+ *
107
+ * @param request - Key transparency client {@link Request}.
108
+ * @param store - Local key transparency storage. It will be queried for both
109
+ * the account data and the latest distinguished tree head before sending the
110
+ * server request and, if the request succeeds, will be updated with the
111
+ * search operation results.
112
+ * @param options - options for the asynchronous operation. Optional.
113
+ *
114
+ * @returns A promise that resolves if the monitor succeeds and the local state has been updated
115
+ * to reflect the latest changes. If the promise is rejected, the UI should be updated to notify
116
+ * the user of the failure.
117
+ */
118
+ monitor(request: Request, store: Store, options?: Readonly<Options>): Promise<void>;
119
+ }
120
+ export declare class ClientImpl implements Client {
121
+ private readonly asyncContext;
122
+ private readonly chatService;
123
+ private readonly env;
124
+ constructor(asyncContext: TokioAsyncContext, chatService: Native.Wrapper<Native.UnauthenticatedChatConnection>, env: Environment);
125
+ search(request: Request, store: Store, options?: Readonly<Options>): Promise<void>;
126
+ monitor(request: Request, store: Store, options?: Readonly<Options>): Promise<void>;
127
+ private updateDistinguished;
128
+ private getLatestDistinguished;
129
+ }
@@ -0,0 +1,50 @@
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.ClientImpl = void 0;
8
+ const Native = require("../../Native");
9
+ const net_1 = require("../net");
10
+ class ClientImpl {
11
+ constructor(asyncContext, chatService, env) {
12
+ this.asyncContext = asyncContext;
13
+ this.chatService = chatService;
14
+ this.env = env;
15
+ }
16
+ async search(request, store, options) {
17
+ const distinguished = await this.getLatestDistinguished(store, options ?? {});
18
+ const { abortSignal } = options ?? {};
19
+ const { aciInfo: { aci, identityKey: aciIdentityKey }, e164Info, usernameHash, } = request;
20
+ const { e164, unidentifiedAccessKey } = e164Info ?? {
21
+ e164: null,
22
+ unidentifiedAccessKey: null,
23
+ };
24
+ const searchResultHandle = await this.asyncContext.makeCancellable(abortSignal, Native.KeyTransparency_Search(this.asyncContext, this.env, this.chatService, aci.getServiceIdFixedWidthBinary(), aciIdentityKey, e164, unidentifiedAccessKey, usernameHash ?? null, await store.getAccountData(aci), distinguished));
25
+ const accountData = Native.SearchResult_GetAccountData((0, net_1.newNativeHandle)(searchResultHandle));
26
+ await store.setAccountData(aci, accountData);
27
+ }
28
+ async monitor(request, store, options) {
29
+ const distinguished = await this.getLatestDistinguished(store, options ?? {});
30
+ const { abortSignal } = options ?? {};
31
+ const { aciInfo: { aci, identityKey: aciIdentityKey }, e164Info, usernameHash, } = request;
32
+ const { e164, unidentifiedAccessKey } = e164Info ?? {
33
+ e164: null,
34
+ unidentifiedAccessKey: null,
35
+ };
36
+ const accountData = await this.asyncContext.makeCancellable(abortSignal, Native.KeyTransparency_Monitor(this.asyncContext, this.env, this.chatService, aci.getServiceIdFixedWidthBinary(), aciIdentityKey, e164, unidentifiedAccessKey, usernameHash ?? null, await store.getAccountData(aci), distinguished));
37
+ await store.setAccountData(aci, accountData);
38
+ }
39
+ async updateDistinguished(store, { abortSignal }) {
40
+ const bytes = await this.asyncContext.makeCancellable(abortSignal, Native.KeyTransparency_Distinguished(this.asyncContext, this.env, this.chatService, await store.getLastDistinguishedTreeHead()));
41
+ await store.setLastDistinguishedTreeHead(bytes);
42
+ return bytes;
43
+ }
44
+ async getLatestDistinguished(store, options) {
45
+ return ((await store.getLastDistinguishedTreeHead()) ??
46
+ (await this.updateDistinguished(store, options)));
47
+ }
48
+ }
49
+ exports.ClientImpl = ClientImpl;
50
+ //# sourceMappingURL=KeyTransparency.js.map
@@ -26,6 +26,7 @@ type ResumeSessionArgs = Readonly<{
26
26
  sessionId: string;
27
27
  e164: string;
28
28
  }>;
29
+ export type Svr2CredentialResult = 'match' | 'no-match' | 'invalid';
29
30
  /**
30
31
  * A client for the Signal registration service.
31
32
  *
@@ -88,8 +89,9 @@ export declare class RegistrationService {
88
89
  languages: string[];
89
90
  }): Promise<void>;
90
91
  verifySession(code: string): Promise<boolean>;
92
+ checkSvr2Credentials(svr2Tokens: Array<string>): Promise<Map<string, Svr2CredentialResult>>;
91
93
  registerAccount(inputs: {
92
- accountPassword: Uint8Array;
94
+ accountPassword: string;
93
95
  skipDeviceTransfer: boolean;
94
96
  accountAttributes: AccountAttributes;
95
97
  aciPublicKey: PublicKey;
@@ -83,10 +83,13 @@ class RegistrationService {
83
83
  await Native.RegistrationService_SubmitVerificationCode(this.tokioAsyncContext, this, code);
84
84
  return this.sessionState.verified;
85
85
  }
86
+ async checkSvr2Credentials(svr2Tokens) {
87
+ return Native.RegistrationService_CheckSvr2Credentials(this.tokioAsyncContext, this, svr2Tokens);
88
+ }
86
89
  async registerAccount(inputs) {
87
90
  const { accountPassword, skipDeviceTransfer = false, accountAttributes, aciPublicKey, pniPublicKey, aciSignedPreKey, pniSignedPreKey, aciPqLastResortPreKey, pniPqLastResortPreKey, } = inputs;
88
91
  const args = (0, net_1.newNativeHandle)(Native.RegisterAccountRequest_Create());
89
- Native.RegisterAccountRequest_SetAccountPassword(args, Buffer.from(accountPassword));
92
+ Native.RegisterAccountRequest_SetAccountPassword(args, accountPassword);
90
93
  if (skipDeviceTransfer) {
91
94
  Native.RegisterAccountRequest_SetSkipDeviceTransfer(args);
92
95
  }
package/dist/net.d.ts CHANGED
@@ -55,6 +55,7 @@ export type ProxyOptions = {
55
55
  /** The "scheme" for Signal TLS proxies. See {@link Net.setProxy()}. */
56
56
  export declare const SIGNAL_TLS_PROXY_SCHEME = "org.signal.tls";
57
57
  export declare class Net {
58
+ private readonly options;
58
59
  private readonly asyncContext;
59
60
  /** Exposed only for testing. */
60
61
  readonly _connectionManager: ConnectionManager;
@@ -177,7 +178,24 @@ export declare class Net {
177
178
  * was set, calling this method is a no-op.
178
179
  */
179
180
  clearProxy(): void;
180
- /** Updates the remote config settings used by libsignal. */
181
+ /**
182
+ * Updates libsignal's remote configuration settings.
183
+ *
184
+ * The provided configuration map must conform to the following requirements:
185
+ * - Each key represents an enabled configuration and directly indicates that the setting is enabled.
186
+ * - Keys must have had the platform-specific prefix (e.g., `"desktop.libsignal."`) removed.
187
+ * - Entries explicitly disabled by the server must not appear in the map.
188
+ * - Values originally set to `null` by the server must be represented as empty strings.
189
+ * - Values should otherwise maintain the same format as they are returned by the server.
190
+ *
191
+ * These constraints ensure configurations passed to libsignal precisely reflect enabled
192
+ * server-provided settings without ambiguity.
193
+ *
194
+ * Only new connections made *after* this call will use the new remote config settings.
195
+ * Existing connections are not affected.
196
+ *
197
+ * @param remoteConfig A map containing preprocessed libsignal configuration keys and their associated values.
198
+ */
181
199
  setRemoteConfig(remoteConfig: Map<string, string>): void;
182
200
  /**
183
201
  * Notifies libsignal that the network has changed.
package/dist/net.js CHANGED
@@ -65,6 +65,7 @@ exports.TokioAsyncContext = TokioAsyncContext;
65
65
  exports.SIGNAL_TLS_PROXY_SCHEME = 'org.signal.tls';
66
66
  class Net {
67
67
  constructor(options) {
68
+ this.options = options;
68
69
  this.asyncContext = new TokioAsyncContext(Native.TokioAsyncContext_new());
69
70
  if (options.localTestServer) {
70
71
  this._connectionManager = newNativeHandle(Native.TESTING_ConnectionManager_newLocalOverride(options.userAgent, options.TESTING_localServer_chatPort, options.TESTING_localServer_cdsiPort, options.TESTING_localServer_svr2Port, options.TESTING_localServer_rootCertificateDer));
@@ -96,7 +97,8 @@ class Net {
96
97
  * @returns the connected listener, if the connection succeeds.
97
98
  */
98
99
  async connectUnauthenticatedChat(listener, options) {
99
- return Chat_1.UnauthenticatedChatConnection.connect(this.asyncContext, this._connectionManager, listener, options);
100
+ const env = this.options.localTestServer ? undefined : this.options.env;
101
+ return Chat_1.UnauthenticatedChatConnection.connect(this.asyncContext, this._connectionManager, listener, env, options);
100
102
  }
101
103
  /**
102
104
  * Creates a new instance of {@link AuthenticatedChatConnection}.
@@ -240,7 +242,24 @@ class Net {
240
242
  clearProxy() {
241
243
  Native.ConnectionManager_clear_proxy(this._connectionManager);
242
244
  }
243
- /** Updates the remote config settings used by libsignal. */
245
+ /**
246
+ * Updates libsignal's remote configuration settings.
247
+ *
248
+ * The provided configuration map must conform to the following requirements:
249
+ * - Each key represents an enabled configuration and directly indicates that the setting is enabled.
250
+ * - Keys must have had the platform-specific prefix (e.g., `"desktop.libsignal."`) removed.
251
+ * - Entries explicitly disabled by the server must not appear in the map.
252
+ * - Values originally set to `null` by the server must be represented as empty strings.
253
+ * - Values should otherwise maintain the same format as they are returned by the server.
254
+ *
255
+ * These constraints ensure configurations passed to libsignal precisely reflect enabled
256
+ * server-provided settings without ambiguity.
257
+ *
258
+ * Only new connections made *after* this call will use the new remote config settings.
259
+ * Existing connections are not affected.
260
+ *
261
+ * @param remoteConfig A map containing preprocessed libsignal configuration keys and their associated values.
262
+ */
244
263
  setRemoteConfig(remoteConfig) {
245
264
  Native.ConnectionManager_set_remote_config(this._connectionManager, new internal_1.BridgedStringMap(remoteConfig));
246
265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalapp/libsignal-client",
3
- "version": "0.70.1",
3
+ "version": "0.71.1",
4
4
  "license": "AGPL-3.0-only",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",