1 // Copyright 2024 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_DEVICE_BOUND_SESSIONS_DEVICE_BOUND_SESSION_REGISTRATION_FETCHER_PARAM_H_ 6 #define NET_DEVICE_BOUND_SESSIONS_DEVICE_BOUND_SESSION_REGISTRATION_FETCHER_PARAM_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/containers/span.h" 12 #include "crypto/signature_verifier.h" 13 #include "net/base/net_export.h" 14 #include "net/http/http_response_headers.h" 15 #include "net/http/structured_headers.h" 16 #include "url/gurl.h" 17 18 namespace net { 19 20 // Class to parse Sec-Session-Registration header. 21 // See explainer for details: 22 // https://github.com/WICG/dbsc/blob/main/README.md#start-session 23 class NET_EXPORT DeviceBoundSessionRegistrationFetcherParam { 24 public: 25 DeviceBoundSessionRegistrationFetcherParam( 26 DeviceBoundSessionRegistrationFetcherParam&& other); 27 DeviceBoundSessionRegistrationFetcherParam& operator=( 28 DeviceBoundSessionRegistrationFetcherParam&& other) noexcept; 29 30 // Disabled to make accidental copies compile errors. 31 DeviceBoundSessionRegistrationFetcherParam( 32 const DeviceBoundSessionRegistrationFetcherParam& other) = delete; 33 DeviceBoundSessionRegistrationFetcherParam& operator=( 34 const DeviceBoundSessionRegistrationFetcherParam&) = delete; 35 ~DeviceBoundSessionRegistrationFetcherParam(); 36 37 // Returns a vector of valid instances. 38 // TODO(chlily): Get IsolationInfo from the request as well 39 static std::vector<DeviceBoundSessionRegistrationFetcherParam> CreateIfValid( 40 const GURL& request_url, 41 const HttpResponseHeaders* headers); 42 registration_endpoint()43 const GURL& registration_endpoint() const { return registration_endpoint_; } 44 45 base::span<const crypto::SignatureVerifier::SignatureAlgorithm> supported_algos()46 supported_algos() const { 47 return supported_algos_; 48 } 49 challenge()50 const std::string& challenge() const { return challenge_; } 51 52 private: 53 DeviceBoundSessionRegistrationFetcherParam( 54 GURL registration_endpoint, 55 std::vector<crypto::SignatureVerifier::SignatureAlgorithm> 56 supported_algos, 57 std::string challenge); 58 static std::optional<DeviceBoundSessionRegistrationFetcherParam> ParseItem( 59 const GURL& request_url, 60 structured_headers::Item item, 61 structured_headers::Parameters params); 62 63 // TODO(chlily): Store last-updated time and last-updated isolationinfo as 64 // needed. 65 GURL registration_endpoint_; 66 std::vector<crypto::SignatureVerifier::SignatureAlgorithm> supported_algos_; 67 std::string challenge_; 68 }; 69 70 } // namespace net 71 72 #endif // NET_DEVICE_BOUND_SESSIONS_DEVICE_BOUND_SESSION_REGISTRATION_FETCHER_PARAM_H_ 73