@signalapp/libsignal-client 0.69.0 → 0.70.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 CHANGED
@@ -130,7 +130,29 @@ type ChatListener = {
130
130
  ): void;
131
131
  };
132
132
 
133
- type RequestedInformation = 'pushChallenge' | 'captcha';
133
+ type RegistrationSessionRequestedInformation = 'pushChallenge' | 'captcha';
134
+
135
+ type RegistrationPushTokenType = 'apn' | 'fcm';
136
+
137
+ type RegistrationCreateSessionRequest = {
138
+ number: string;
139
+ push_token?: string;
140
+ push_token_type?: RegistrationPushTokenType;
141
+ mcc?: string;
142
+ mnc?: string;
143
+ };
144
+
145
+ type RegisterResponseBadge = {
146
+ id: string;
147
+ visible: boolean;
148
+ expirationSeconds: number;
149
+ };
150
+
151
+ type SignedPublicPreKey = {
152
+ keyId: number;
153
+ publicKey: Buffer;
154
+ signature: Buffer;
155
+ };
134
156
 
135
157
  type Wrapper<T> = Readonly<{
136
158
  _nativeHandle: T;
@@ -195,6 +217,8 @@ export function BackupKey_DeriveLocalBackupMetadataKey(backupKey: Buffer): Buffe
195
217
  export function BackupKey_DeriveMediaEncryptionKey(backupKey: Buffer, mediaId: Buffer): Buffer;
196
218
  export function BackupKey_DeriveMediaId(backupKey: Buffer, mediaName: string): Buffer;
197
219
  export function BackupKey_DeriveThumbnailTransitEncryptionKey(backupKey: Buffer, mediaId: Buffer): Buffer;
220
+ export function BridgedStringMap_insert(map: Wrapper<BridgedStringMap>, key: string, value: string): void;
221
+ export function BridgedStringMap_new(initialCapacity: number): BridgedStringMap;
198
222
  export function CallLinkAuthCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
199
223
  export function CallLinkAuthCredentialPresentation_GetUserId(presentationBytes: Buffer): Serialized<UuidCiphertext>;
200
224
  export function CallLinkAuthCredentialPresentation_Verify(presentationBytes: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
@@ -207,6 +231,7 @@ export function CallLinkPublicParams_CheckValidContents(paramsBytes: Buffer): vo
207
231
  export function CallLinkSecretParams_CheckValidContents(paramsBytes: Buffer): void;
208
232
  export function CallLinkSecretParams_DecryptUserId(paramsBytes: Buffer, userId: Serialized<UuidCiphertext>): Buffer;
209
233
  export function CallLinkSecretParams_DeriveFromRootKey(rootKey: Buffer): Buffer;
234
+ export function CallLinkSecretParams_EncryptUserId(paramsBytes: Buffer, userId: Buffer): Serialized<UuidCiphertext>;
210
235
  export function CallLinkSecretParams_GetPublicParams(paramsBytes: Buffer): Buffer;
211
236
  export function Cds2ClientState_New(mrenclave: Buffer, attestationMsg: Buffer, currentTimestamp: Timestamp): SgxClientState;
212
237
  export function CdsiLookup_complete(asyncRuntime: Wrapper<TokioAsyncContext>, lookup: Wrapper<CdsiLookup>): CancellablePromise<LookupResponse>;
@@ -222,12 +247,13 @@ export function ComparableBackup_GetComparableString(backup: Wrapper<ComparableB
222
247
  export function ComparableBackup_GetUnknownFields(backup: Wrapper<ComparableBackup>): string[];
223
248
  export function ComparableBackup_ReadUnencrypted(stream: InputStream, len: bigint, purpose: number): Promise<ComparableBackup>;
224
249
  export function ConnectionManager_clear_proxy(connectionManager: Wrapper<ConnectionManager>): void;
225
- export function ConnectionManager_new(environment: number, userAgent: string): ConnectionManager;
250
+ export function ConnectionManager_new(environment: number, userAgent: string, remoteConfig: Wrapper<BridgedStringMap>): ConnectionManager;
226
251
  export function ConnectionManager_on_network_change(connectionManager: Wrapper<ConnectionManager>): void;
227
252
  export function ConnectionManager_set_censorship_circumvention_enabled(connectionManager: Wrapper<ConnectionManager>, enabled: boolean): void;
228
253
  export function ConnectionManager_set_invalid_proxy(connectionManager: Wrapper<ConnectionManager>): void;
229
254
  export function ConnectionManager_set_ipv6_enabled(connectionManager: Wrapper<ConnectionManager>, ipv6Enabled: boolean): void;
230
255
  export function ConnectionManager_set_proxy(connectionManager: Wrapper<ConnectionManager>, proxy: Wrapper<ConnectionProxyConfig>): void;
256
+ export function ConnectionManager_set_remote_config(connectionManager: Wrapper<ConnectionManager>, remoteConfig: Wrapper<BridgedStringMap>): void;
231
257
  export function ConnectionProxyConfig_new(scheme: string, host: string, port: number, username: string | null, password: string | null): ConnectionProxyConfig;
232
258
  export function CreateCallLinkCredentialPresentation_CheckValidContents(presentationBytes: Buffer): void;
233
259
  export function CreateCallLinkCredentialPresentation_Verify(presentationBytes: Buffer, roomId: Buffer, now: Timestamp, serverParamsBytes: Buffer, callLinkParamsBytes: Buffer): void;
@@ -277,6 +303,7 @@ export function GroupSecretParams_GetMasterKey(params: Serialized<GroupSecretPar
277
303
  export function GroupSecretParams_GetPublicParams(params: Serialized<GroupSecretParams>): Serialized<GroupPublicParams>;
278
304
  export function GroupSendDerivedKeyPair_CheckValidContents(bytes: Buffer): void;
279
305
  export function GroupSendDerivedKeyPair_ForExpiration(expiration: Timestamp, serverParams: Wrapper<ServerSecretParams>): Buffer;
306
+ export function GroupSendEndorsement_CallLinkParams_ToToken(endorsement: Buffer, callLinkSecretParamsSerialized: Buffer): Buffer;
280
307
  export function GroupSendEndorsement_CheckValidContents(bytes: Buffer): void;
281
308
  export function GroupSendEndorsement_Combine(endorsements: Buffer[]): Buffer;
282
309
  export function GroupSendEndorsement_Remove(endorsement: Buffer, toRemove: Buffer): Buffer;
@@ -331,7 +358,6 @@ export function LookupRequest_new(): LookupRequest;
331
358
  export function LookupRequest_setToken(request: Wrapper<LookupRequest>, token: Buffer): void;
332
359
  export function MessageBackupKey_FromAccountEntropyPool(accountEntropy: AccountEntropyPool, aci: Buffer): MessageBackupKey;
333
360
  export function MessageBackupKey_FromBackupKeyAndBackupId(backupKey: Buffer, backupId: Buffer): MessageBackupKey;
334
- export function MessageBackupKey_FromMasterKey(masterKey: Buffer, aci: Buffer): MessageBackupKey;
335
361
  export function MessageBackupKey_GetAesKey(key: Wrapper<MessageBackupKey>): Buffer;
336
362
  export function MessageBackupKey_GetHmacKey(key: Wrapper<MessageBackupKey>): Buffer;
337
363
  export function MessageBackupValidator_Validate(key: Wrapper<MessageBackupKey>, firstStream: InputStream, secondStream: InputStream, len: bigint, purpose: number): Promise<MessageBackupValidationOutcome>;
@@ -407,11 +433,28 @@ export function ReceiptCredentialResponse_CheckValidContents(buffer: Buffer): vo
407
433
  export function ReceiptCredential_CheckValidContents(buffer: Buffer): void;
408
434
  export function ReceiptCredential_GetReceiptExpirationTime(receiptCredential: Serialized<ReceiptCredential>): Timestamp;
409
435
  export function ReceiptCredential_GetReceiptLevel(receiptCredential: Serialized<ReceiptCredential>): bigint;
410
- export function RegistrationService_CreateSession(asyncRuntime: Wrapper<TokioAsyncContext>, createSession: CreateSession, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
436
+ export function RegisterAccountRequest_Create(): RegisterAccountRequest;
437
+ export function RegisterAccountRequest_SetAccountPassword(registerAccount: Wrapper<RegisterAccountRequest>, accountPassword: Buffer): void;
438
+ export function RegisterAccountRequest_SetIdentityPqLastResortPreKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, pqLastResortPreKey: SignedPublicPreKey): void;
439
+ export function RegisterAccountRequest_SetIdentityPublicKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, identityKey: Wrapper<PublicKey>): void;
440
+ export function RegisterAccountRequest_SetIdentitySignedPreKey(registerAccount: Wrapper<RegisterAccountRequest>, identityType: number, signedPreKey: SignedPublicPreKey): void;
441
+ export function RegisterAccountRequest_SetSkipDeviceTransfer(registerAccount: Wrapper<RegisterAccountRequest>): void;
442
+ export function RegisterAccountResponse_GetEntitlementBackupExpirationSeconds(response: Wrapper<RegisterAccountResponse>): bigint | null;
443
+ export function RegisterAccountResponse_GetEntitlementBackupLevel(response: Wrapper<RegisterAccountResponse>): bigint | null;
444
+ export function RegisterAccountResponse_GetEntitlementBadges(response: Wrapper<RegisterAccountResponse>): RegisterResponseBadge[];
445
+ export function RegisterAccountResponse_GetIdentity(response: Wrapper<RegisterAccountResponse>, identityType: number): Buffer;
446
+ export function RegisterAccountResponse_GetNumber(response: Wrapper<RegisterAccountResponse>): string;
447
+ export function RegisterAccountResponse_GetReregistration(response: Wrapper<RegisterAccountResponse>): boolean;
448
+ export function RegisterAccountResponse_GetStorageCapable(response: Wrapper<RegisterAccountResponse>): boolean;
449
+ export function RegisterAccountResponse_GetUsernameHash(response: Wrapper<RegisterAccountResponse>): Buffer | null;
450
+ export function RegisterAccountResponse_GetUsernameLinkHandle(response: Wrapper<RegisterAccountResponse>): Uuid | null;
451
+ export function RegistrationAccountAttributes_Create(recoveryPassword: Buffer, aciRegistrationId: number, pniRegistrationId: number, registrationLock: string | null, unidentifiedAccessKey: Buffer | null, unrestrictedUnidentifiedAccess: boolean, capabilities: string[], discoverableByPhoneNumber: boolean): RegistrationAccountAttributes;
452
+ export function RegistrationService_CreateSession(asyncRuntime: Wrapper<TokioAsyncContext>, createSession: RegistrationCreateSessionRequest, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
453
+ export function RegistrationService_RegisterAccount(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, registerAccount: Wrapper<RegisterAccountRequest>, accountAttributes: Wrapper<RegistrationAccountAttributes>): CancellablePromise<RegisterAccountResponse>;
411
454
  export function RegistrationService_RegistrationSession(service: Wrapper<RegistrationService>): RegistrationSession;
412
- export function RegistrationService_RequestPushChallenge(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, pushToken: string, pushTokenType: PushTokenType): CancellablePromise<void>;
413
- export function RegistrationService_RequestVerificationCode(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, transport: string, client: string): CancellablePromise<void>;
414
- export function RegistrationService_ResumeSession(asyncRuntime: Wrapper<TokioAsyncContext>, sessionId: string, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
455
+ export function RegistrationService_RequestPushChallenge(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, pushToken: string, pushTokenType: RegistrationPushTokenType): CancellablePromise<void>;
456
+ export function RegistrationService_RequestVerificationCode(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, transport: string, client: string, languages: string[]): CancellablePromise<void>;
457
+ export function RegistrationService_ResumeSession(asyncRuntime: Wrapper<TokioAsyncContext>, sessionId: string, number: string, connectChat: ConnectChatBridge): CancellablePromise<RegistrationService>;
415
458
  export function RegistrationService_SessionId(service: Wrapper<RegistrationService>): string;
416
459
  export function RegistrationService_SubmitCaptcha(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, captchaValue: string): CancellablePromise<void>;
417
460
  export function RegistrationService_SubmitPushChallenge(asyncRuntime: Wrapper<TokioAsyncContext>, service: Wrapper<RegistrationService>, pushChallenge: string): CancellablePromise<void>;
@@ -420,7 +463,7 @@ export function RegistrationSession_GetAllowedToRequestCode(session: Wrapper<Reg
420
463
  export function RegistrationSession_GetNextCallSeconds(session: Wrapper<RegistrationSession>): number | null;
421
464
  export function RegistrationSession_GetNextSmsSeconds(session: Wrapper<RegistrationSession>): number | null;
422
465
  export function RegistrationSession_GetNextVerificationAttemptSeconds(session: Wrapper<RegistrationSession>): number | null;
423
- export function RegistrationSession_GetRequestedInformation(session: Wrapper<RegistrationSession>): RequestedInformation[];
466
+ export function RegistrationSession_GetRequestedInformation(session: Wrapper<RegistrationSession>): RegistrationSessionRequestedInformation[];
424
467
  export function RegistrationSession_GetVerified(session: Wrapper<RegistrationSession>): boolean;
425
468
  export function SanitizedMetadata_GetDataLen(sanitized: Wrapper<SanitizedMetadata>): bigint;
426
469
  export function SanitizedMetadata_GetDataOffset(sanitized: Wrapper<SanitizedMetadata>): bigint;
@@ -534,6 +577,7 @@ export function SignedPreKeyRecord_GetSignature(obj: Wrapper<SignedPreKeyRecord>
534
577
  export function SignedPreKeyRecord_GetTimestamp(obj: Wrapper<SignedPreKeyRecord>): Timestamp;
535
578
  export function SignedPreKeyRecord_New(id: number, timestamp: Timestamp, pubKey: Wrapper<PublicKey>, privKey: Wrapper<PrivateKey>, signature: Buffer): SignedPreKeyRecord;
536
579
  export function SignedPreKeyRecord_Serialize(obj: Wrapper<SignedPreKeyRecord>): Buffer;
580
+ export function TESTING_BridgedStringMap_dump_to_json(map: Wrapper<BridgedStringMap>): string;
537
581
  export function TESTING_CdsiLookupErrorConvert(errorDescription: string): void;
538
582
  export function TESTING_CdsiLookupResponseConvert(asyncRuntime: Wrapper<TokioAsyncContext>): CancellablePromise<LookupResponse>;
539
583
  export function TESTING_ChatConnectErrorConvert(errorDescription: string): void;
@@ -560,13 +604,19 @@ export function TESTING_FakeChatRemoteEnd_InjectConnectionInterrupted(chat: Wrap
560
604
  export function TESTING_FakeChatRemoteEnd_ReceiveIncomingRequest(asyncRuntime: Wrapper<TokioAsyncContext>, chat: Wrapper<FakeChatRemoteEnd>): CancellablePromise<FakeChatSentRequest | null>;
561
605
  export function TESTING_FakeChatRemoteEnd_SendRawServerRequest(chat: Wrapper<FakeChatRemoteEnd>, bytes: Buffer): void;
562
606
  export function TESTING_FakeChatRemoteEnd_SendRawServerResponse(chat: Wrapper<FakeChatRemoteEnd>, bytes: Buffer): void;
607
+ export function TESTING_FakeChatRemoteEnd_SendServerResponse(chat: Wrapper<FakeChatRemoteEnd>, response: Wrapper<FakeChatResponse>): void;
608
+ export function TESTING_FakeChatResponse_Create(id: bigint, status: number, message: string, headers: string[], body: Buffer | null): FakeChatResponse;
563
609
  export function TESTING_FakeChatSentRequest_RequestId(request: Wrapper<FakeChatSentRequest>): bigint;
564
610
  export function TESTING_FakeChatSentRequest_TakeHttpRequest(request: Wrapper<FakeChatSentRequest>): HttpRequest;
611
+ export function TESTING_FakeChatServer_Create(): FakeChatServer;
612
+ export function TESTING_FakeChatServer_GetNextRemote(asyncRuntime: Wrapper<TokioAsyncContext>, server: Wrapper<FakeChatServer>): CancellablePromise<FakeChatRemoteEnd>;
613
+ export function TESTING_FakeRegistrationSession_CreateSession(asyncRuntime: Wrapper<TokioAsyncContext>, createSession: RegistrationCreateSessionRequest, chat: Wrapper<FakeChatServer>): CancellablePromise<RegistrationService>;
565
614
  export function TESTING_FutureFailure(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, _input: number): CancellablePromise<number>;
566
615
  export function TESTING_FutureProducesOtherPointerType(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, input: string): CancellablePromise<OtherTestingHandleType>;
567
616
  export function TESTING_FutureProducesPointerType(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, input: number): CancellablePromise<TestingHandleType>;
568
617
  export function TESTING_FutureSuccess(asyncRuntime: Wrapper<NonSuspendingBackgroundThreadRuntime>, input: number): CancellablePromise<number>;
569
618
  export function TESTING_InputStreamReadIntoZeroLengthSlice(capsAlphabetInput: InputStream): Promise<Buffer>;
619
+ export function TESTING_JoinStringArray(array: string[], joinWith: string): string;
570
620
  export function TESTING_NonSuspendingBackgroundThreadRuntime_New(): NonSuspendingBackgroundThreadRuntime;
571
621
  export function TESTING_OnlyCompletesByCancellation(asyncRuntime: Wrapper<TokioAsyncContext>): CancellablePromise<void>;
572
622
  export function TESTING_OtherTestingHandleType_getValue(handle: Wrapper<OtherTestingHandleType>): string;
@@ -628,6 +678,7 @@ export function initLogger(maxLevel: LogLevel, callback: (level: LogLevel, targe
628
678
  export function test_only_fn_returns_123(): number;
629
679
  interface Aes256GcmSiv { readonly __type: unique symbol; }
630
680
  interface AuthenticatedChatConnection { readonly __type: unique symbol; }
681
+ interface BridgedStringMap { readonly __type: unique symbol; }
631
682
  interface CdsiLookup { readonly __type: unique symbol; }
632
683
  interface ChatConnectionInfo { readonly __type: unique symbol; }
633
684
  interface CiphertextMessage { readonly __type: unique symbol; }
@@ -640,7 +691,9 @@ interface ExpiringProfileKeyCredential { readonly __type: unique symbol; }
640
691
  interface ExpiringProfileKeyCredentialResponse { readonly __type: unique symbol; }
641
692
  interface FakeChatConnection { readonly __type: unique symbol; }
642
693
  interface FakeChatRemoteEnd { readonly __type: unique symbol; }
694
+ interface FakeChatResponse { readonly __type: unique symbol; }
643
695
  interface FakeChatSentRequest { readonly __type: unique symbol; }
696
+ interface FakeChatServer { readonly __type: unique symbol; }
644
697
  interface Fingerprint { readonly __type: unique symbol; }
645
698
  interface GroupMasterKey { readonly __type: unique symbol; }
646
699
  interface GroupPublicParams { readonly __type: unique symbol; }
@@ -674,6 +727,9 @@ interface ReceiptCredentialPresentation { readonly __type: unique symbol; }
674
727
  interface ReceiptCredentialRequest { readonly __type: unique symbol; }
675
728
  interface ReceiptCredentialRequestContext { readonly __type: unique symbol; }
676
729
  interface ReceiptCredentialResponse { readonly __type: unique symbol; }
730
+ interface RegisterAccountRequest { readonly __type: unique symbol; }
731
+ interface RegisterAccountResponse { readonly __type: unique symbol; }
732
+ interface RegistrationAccountAttributes { readonly __type: unique symbol; }
677
733
  interface RegistrationService { readonly __type: unique symbol; }
678
734
  interface RegistrationSession { readonly __type: unique symbol; }
679
735
  interface SanitizedMetadata { readonly __type: unique symbol; }
@@ -44,14 +44,6 @@ export type MessageBackupKeyInput = Readonly<{
44
44
  */
45
45
  export declare class MessageBackupKey {
46
46
  readonly _nativeHandle: Native.MessageBackupKey;
47
- /**
48
- * Create a backup bundle key from the given master key and ACI.
49
- *
50
- * `masterKeyBytes` should contain exactly 32 bytes.
51
- *
52
- * @deprecated Use AccountEntropyPool instead.
53
- */
54
- constructor(masterKeyBytes: Buffer, aci: Aci);
55
47
  /**
56
48
  * Create a backup bundle key from an account entropy pool and ACI.
57
49
  *
@@ -37,19 +37,24 @@ exports.ValidationOutcome = ValidationOutcome;
37
37
  * @see {@link BackupKey}
38
38
  */
39
39
  class MessageBackupKey {
40
- constructor(inputOrMasterKeyBytes, maybeAci) {
41
- if (inputOrMasterKeyBytes instanceof Buffer) {
42
- if (maybeAci === undefined)
43
- throw new Error('missing ACI parameter');
44
- this._nativeHandle = Native.MessageBackupKey_FromMasterKey(inputOrMasterKeyBytes, maybeAci.getServiceIdFixedWidthBinary());
45
- }
46
- else if ('accountEntropy' in inputOrMasterKeyBytes) {
47
- const { accountEntropy, aci } = inputOrMasterKeyBytes;
40
+ /**
41
+ * Create a backup bundle key from an account entropy pool and ACI.
42
+ *
43
+ * ...or from a backup key and ID, used when reading from a local backup, which may have been
44
+ * created with a different ACI. This still uses AccountEntropyPool-based key derivation rules; it
45
+ * cannot be used to read a backup created from a master key.
46
+ *
47
+ * The account entropy pool must be **validated**; passing an arbitrary string here is considered
48
+ * a programmer error. Similarly, passing a backup key or ID of the wrong length is also an error.
49
+ */
50
+ constructor(input) {
51
+ if ('accountEntropy' in input) {
52
+ const { accountEntropy, aci } = input;
48
53
  this._nativeHandle = Native.MessageBackupKey_FromAccountEntropyPool(accountEntropy, aci.getServiceIdFixedWidthBinary());
49
54
  }
50
55
  else {
51
- const { backupId } = inputOrMasterKeyBytes;
52
- let { backupKey } = inputOrMasterKeyBytes;
56
+ const { backupId } = input;
57
+ let { backupKey } = input;
53
58
  if (backupKey instanceof AccountKeys_1.BackupKey) {
54
59
  backupKey = backupKey.contents;
55
60
  }