LCOV - code coverage report
Current view: top level - util - at_client_util.dart (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 14 24 58.3 %
Date: 2022-01-19 17:54:05 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:convert';
       2             : import 'dart:typed_data';
       3             : 
       4             : import 'package:at_commons/at_builders.dart';
       5             : import 'package:at_commons/at_commons.dart';
       6             : import 'package:at_lookup/at_lookup.dart';
       7             : import 'package:at_utils/at_utils.dart';
       8             : import 'package:crypton/crypton.dart';
       9             : 
      10             : class AtClientUtil {
      11           2 :   static String buildKey(UpdateVerbBuilder builder) {
      12             :     var updateKey = '';
      13           2 :     if (builder.isPublic) {
      14           2 :       updateKey += 'public:';
      15             :     }
      16           2 :     if (builder.sharedWith != null) {
      17           4 :       updateKey += '${AtUtils.formatAtSign(builder.sharedWith!)}:';
      18             :     }
      19           4 :     updateKey += builder.atKey!;
      20           2 :     if (builder.sharedBy != null) {
      21           6 :       updateKey += AtUtils.formatAtSign(builder.sharedBy)!;
      22             :     }
      23             :     return updateKey;
      24             :   }
      25             : 
      26           0 :   static Future<String> findSecondary(
      27             :       String toAtSign, String rootDomain, int rootPort) async {
      28             :     var secondaryUrl =
      29           0 :         await AtLookupImpl.findSecondary(toAtSign, rootDomain, rootPort);
      30             :     if (secondaryUrl == null) {
      31           0 :       throw SecondaryNotFoundException(
      32           0 :           'No secondary url found for atsign: $toAtSign');
      33             :     }
      34             :     return secondaryUrl;
      35             :   }
      36             : 
      37           1 :   static List<String> getSecondaryInfo(String? url) {
      38           1 :     var result = <String>[];
      39           1 :     if (url != null && url.contains(':')) {
      40           1 :       var arr = url.split(':');
      41           2 :       result.add(arr[0]);
      42           2 :       result.add(arr[1]);
      43             :     }
      44             :     return result;
      45             :   }
      46             : 
      47           0 :   static String signChallenge(String challenge, String privateKey) {
      48           0 :     var key = RSAPrivateKey.fromString(privateKey);
      49           0 :     challenge = challenge.trim();
      50             :     var signature =
      51           0 :         key.createSHA256Signature(utf8.encode(challenge) as Uint8List);
      52           0 :     return base64Encode(signature);
      53             :   }
      54             : 
      55           0 :   static bool isAnyNotNull(
      56             :       {dynamic a1,
      57             :       dynamic a2,
      58             :       dynamic a3,
      59             :       dynamic a4,
      60             :       dynamic a5,
      61             :       dynamic a6}) {
      62             :     return ((a1 != null) ||
      63             :             (a2 != null) ||
      64             :             (a3 != null) ||
      65             :             (a4 != null) ||
      66             :             (a5 != null)) ||
      67             :         (a6 != null);
      68             :   }
      69             : }

Generated by: LCOV version 1.13