chromium/chrome/browser/webauthn/cablev2_devices.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/webauthn/cablev2_devices.h"

#include <array>
#include <string>
#include <string_view>
#include <vector>

#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/i18n/time_formatting.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/device_info_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/sync_device_info/device_info.h"
#include "components/sync_device_info/device_info_sync_service.h"
#include "components/sync_device_info/device_info_tracker.h"
#include "device/fido/cable/cable_discovery_data.h"
#include "device/fido/cable/v2_constants.h"
#include "device/fido/cable/v2_handshake.h"
#include "device/fido/features.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"

Pairing;

namespace cablev2 {

namespace {

template <size_t N>
bool CopyBytestring(std::array<uint8_t, N>* out, const std::string* value) {}

bool CopyBytestring(std::vector<uint8_t>* out, const std::string* value) {}

bool CopyString(std::string* out, const std::string* value) {}

const char kWebAuthnCablePairingsPrefName[] =;

// The `kWebAuthnCablePairingsPrefName` preference contains a list of dicts,
// where each dict has these keys:
const char kPairingPrefName[] =;
const char kPairingPrefContactId[] =;
// This used to be "tunnel_server" and contain the decoded domain as a string.
const char kPairingPrefEncodedTunnelServer[] =;
const char kPairingPrefId[] =;
const char kPairingPrefSecret[] =;
const char kPairingPrefPublicKey[] =;
const char kPairingPrefTime[] =;
const char kPairingPrefNewImpl[] =;

// NameForDisplay removes line-breaking characters from `raw_name` to ensure
// that the transport-selection UI isn't too badly broken by nonsense names.
static std::string NameForDisplay(std::string_view raw_name) {}

// DeletePairingByPublicKey erases any pairing with the given public key
// from `list`.
void DeletePairingByPublicKey(base::Value::List& list,
                              const std::string& public_key_base64) {}

std::vector<std::unique_ptr<Pairing>> GetSyncedDevices(Profile* const profile) {}

std::vector<std::unique_ptr<Pairing>> GetLinkedDevices(Profile* const profile) {}

// FindUniqueName checks whether |name| is already contained in |existing_names|
// (after projecting with |NameForDisplay|). If so it appends a counter so that
// it isn't.
std::string FindUniqueName(const std::string& orig_name,
                           base::span<const std::string_view> existing_names) {}

}  // namespace

// PairingFromSyncedDevice extracts the caBLEv2 information from Sync's
// DeviceInfo (if any) into a caBLEv2 pairing. It may return nullptr.
std::unique_ptr<Pairing> PairingFromSyncedDevice(
    const syncer::DeviceInfo* device,
    const base::Time& now) {}

void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {}

KnownDevices::KnownDevices() = default;
KnownDevices::~KnownDevices() = default;

// static
std::unique_ptr<KnownDevices> KnownDevices::FromProfile(Profile* profile) {}

std::vector<std::unique_ptr<Pairing>> MergeDevices(
    std::unique_ptr<KnownDevices> known_devices,
    const icu::Locale* locale) {}

std::vector<std::string_view> KnownDevices::Names() const {}

void AddPairing(Profile* profile, std::unique_ptr<Pairing> pairing) {}

// DeletePairingByPublicKey erases any pairing with the given public key
// from `list`.
void DeletePairingByPublicKey(
    PrefService* pref_service,
    std::array<uint8_t, device::kP256X962Length> public_key) {}

bool RenamePairing(
    PrefService* pref_service,
    const std::array<uint8_t, device::kP256X962Length>& public_key,
    const std::string& new_name,
    base::span<const std::string_view> existing_names) {}

}  // namespace cablev2