14
14
using libsignalservice . push . http ;
15
15
using libsignalservice . util ;
16
16
using libsignalservice . websocket ;
17
+ using Microsoft . Extensions . Logging ;
17
18
using org . whispersystems . curve25519 ;
18
19
using Org . BouncyCastle . Crypto ;
19
20
using Strilanc . Value ;
20
21
using System ;
21
22
using System . Collections . Generic ;
23
+ using System . IO ;
22
24
using System . Text ;
23
25
using System . Threading ;
24
26
using System . Threading . Tasks ;
@@ -31,6 +33,7 @@ namespace libsignalservice
31
33
/// </summary>
32
34
public class SignalServiceAccountManager
33
35
{
36
+ private readonly ILogger Logger = LibsignalLogging . CreateLogger < SignalServiceAccountManager > ( ) ;
34
37
private PushServiceSocket PushServiceSocket ;
35
38
private static ProvisioningSocket ProvisioningSocket ;
36
39
private SignalServiceConfiguration Configuration ;
@@ -260,13 +263,13 @@ public async Task<IList<string>> GetRegisteredUsers(IList<string> e164numbers, s
260
263
}
261
264
try
262
265
{
263
- string authorizationToken = await PushServiceSocket . GetContactDiscoveryAuthorization ( token ) ;
266
+ string authorization = await PushServiceSocket . GetContactDiscoveryAuthorization ( token ) ;
264
267
Curve25519 curve = Curve25519 . getInstance ( Curve25519 . BEST ) ;
265
268
org . whispersystems . curve25519 . Curve25519KeyPair keyPair = curve . generateKeyPair ( ) ;
266
269
267
270
ContactDiscoveryCipher cipher = new ContactDiscoveryCipher ( ) ;
268
271
RemoteAttestationRequest attestationRequest = new RemoteAttestationRequest ( keyPair . getPublicKey ( ) ) ;
269
- ( RemoteAttestationResponse , IList < string > ) attestationResponse = await PushServiceSocket . GetContactDiscoveryRemoteAttestation ( authorizationToken , attestationRequest , mrenclave , token ) ;
272
+ ( RemoteAttestationResponse , IList < string > ) attestationResponse = await PushServiceSocket . GetContactDiscoveryRemoteAttestation ( authorization , attestationRequest , mrenclave , token ) ;
270
273
271
274
RemoteAttestationKeys keys = new RemoteAttestationKeys ( keyPair , attestationResponse . Item1 . ServerEphemeralPublic ! , attestationResponse . Item1 . ServerStaticPublic ! ) ;
272
275
Quote quote = new Quote ( attestationResponse . Item1 . Quote ! ) ;
@@ -284,7 +287,7 @@ public async Task<IList<string>> GetRegisteredUsers(IList<string> e164numbers, s
284
287
}
285
288
286
289
DiscoveryRequest request = cipher . CreateDiscoveryRequest ( addressBook , remoteAttestation ) ;
287
- DiscoveryResponse response = await PushServiceSocket . GetContactDiscoveryRegisteredUsers ( authorizationToken , request , attestationResponse . Item2 , mrenclave , token ) ;
290
+ DiscoveryResponse response = await PushServiceSocket . GetContactDiscoveryRegisteredUsers ( authorization , request , attestationResponse . Item2 , mrenclave , token ) ;
288
291
byte [ ] data = cipher . GetDiscoveryResponseData ( response , remoteAttestation ) ;
289
292
290
293
IEnumerator < string > addressBookIterator = addressBook . GetEnumerator ( ) ;
@@ -307,6 +310,74 @@ public async Task<IList<string>> GetRegisteredUsers(IList<string> e164numbers, s
307
310
}
308
311
}
309
312
313
+ public async Task ReportContactDiscoveryServiceMatch ( CancellationToken ? token = null )
314
+ {
315
+ if ( token == null )
316
+ {
317
+ token = CancellationToken . None ;
318
+ }
319
+
320
+ try
321
+ {
322
+ await PushServiceSocket . ReportContactDiscoveryServiceMatch ( token ) ;
323
+ }
324
+ catch ( IOException ex )
325
+ {
326
+ Logger . LogInformation ( new EventId ( ) , ex , "Request to indicate a contact discovery result match failed. Ignoring." ) ;
327
+ }
328
+ }
329
+
330
+ public async Task ReportContactDiscoveryServiceMismatch ( CancellationToken ? token = null )
331
+ {
332
+ if ( token == null )
333
+ {
334
+ token = CancellationToken . None ;
335
+ }
336
+
337
+ try
338
+ {
339
+ await PushServiceSocket . ReportContactDiscoveryServiceMismatch ( ) ;
340
+ }
341
+ catch ( IOException ex )
342
+ {
343
+ Logger . LogInformation ( new EventId ( ) , ex , "Request to indicate a contact discovery result mismatch failed. Ignoring." ) ;
344
+ }
345
+ }
346
+
347
+ public async Task ReportContactDiscoveryServiceAttestationError ( CancellationToken ? token = null )
348
+ {
349
+ if ( token == null )
350
+ {
351
+ token = CancellationToken . None ;
352
+ }
353
+
354
+ try
355
+ {
356
+ await PushServiceSocket . ReportContactDiscoveryServiceAttestationError ( token ) ;
357
+ }
358
+ catch ( IOException ex )
359
+ {
360
+ Logger . LogInformation ( new EventId ( ) , ex , "Request to indicate a contact discovery attestation error failed. Ignoring." ) ;
361
+ }
362
+ }
363
+
364
+ public async Task ReportContactDiscoveryServiceUnexpectedError ( CancellationToken ? token = null )
365
+ {
366
+ if ( token == null )
367
+ {
368
+ token = CancellationToken . None ;
369
+ }
370
+
371
+ try
372
+ {
373
+ await PushServiceSocket . ReportContactDiscoveryServiceUnexpectedError ( token ) ;
374
+ }
375
+ catch ( IOException ex )
376
+ {
377
+ Logger . LogInformation ( new EventId ( ) , ex , "Request to indicate a contact discovery unexpected error failed. Ignoring." ) ;
378
+ }
379
+ }
380
+
310
381
/// <summary>
311
382
/// Request a UUID from the server for linking as a new device.
312
383
/// Called by the new device.
0 commit comments