initialize static method

Future<void> initialize({
  1. String? apiKey,
  2. String? encryptionKey,
  3. String? apiUrl,
  4. String? namespace,
  5. TransportCredentials? transportCredentials,
  6. bool? debug,
  7. bool? recordActive,
})

Implementation

static Future<void> initialize({
  String? apiKey,
  String? encryptionKey,
  String? apiUrl,
  String? namespace,
  TransportCredentials? transportCredentials,
  bool? debug,
  bool? recordActive,
}) async {
  // set values
  _encryptionKey = encryptionKey ?? "";
  _apiKey = apiKey ?? "";
  _namespace = namespace ?? "";
  _apiUrl = apiUrl ?? _apiUrl;
  _grpcUserClient = await NuntioChannel.userServiceClient(_apiUrl);
  _grpcCloudClient = await NuntioChannel.cloudServiceClient(_apiUrl);
  // build authorize
  Authorize authorize =
      NuntioAuthorize(projectClient: _grpcCloudClient, apiKey: _apiKey);
  // get block user public key
  UserRequest publicKeysReq = UserRequest();
  publicKeysReq.cloudToken = await authorize.getAccessToken();
  UserResponse publicKeysResp =
      await _grpcUserClient.publicKeys(publicKeysReq);
  //todo: find out why this is empty
  String? jwtPublicKey = publicKeysResp.publicKeys["public-jwt-key"];
  // biometric storage
  userBlock = UserBlock(
    grpcUserClient: _grpcUserClient,
    encryptionKey: _encryptionKey,
    jwtPublicKey: jwtPublicKey,
    authorize: authorize,
    debug: debug,
    recordActive: recordActive,
    sharedPreferences: await SharedPreferences.getInstance(),
  );
}