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_SESSION_PARAMS_H_ 6 #define NET_DEVICE_BOUND_SESSIONS_SESSION_PARAMS_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "net/base/net_export.h" 12 13 namespace net::device_bound_sessions { 14 15 // Struct to contain the parameters from the session instruction JSON. 16 // https://github.com/WICG/dbsc/blob/main/README.md#session-registration-instructions-json 17 // This is sent on session creation and session refresh 18 struct NET_EXPORT SessionParams final { 19 // Scope section of session instructions. 20 struct NET_EXPORT Scope { 21 // Specification section of the session scope instructions. 22 struct NET_EXPORT Specification { 23 enum class Type { kExclude, kInclude }; 24 bool operator==(const Specification&) const = default; 25 Type type; 26 std::string domain; 27 std::string path; 28 }; 29 30 // Defaults to false if not in the params 31 bool include_site = false; 32 std::vector<Specification> specifications; 33 34 Scope(); 35 Scope(Scope&& other) noexcept; 36 Scope& operator=(Scope&& other) noexcept; 37 ~Scope(); 38 }; 39 40 // Credential section of the session instruction. 41 struct NET_EXPORT Credential { 42 bool operator==(const Credential&) const = default; 43 std::string name; 44 std::string attributes; 45 }; 46 47 SessionParams(std::string id, 48 std::string refresh_url, 49 Scope scope, 50 std::vector<Credential> creds); 51 SessionParams(SessionParams&& other) noexcept; 52 SessionParams& operator=(SessionParams&& other) noexcept; 53 54 ~SessionParams(); 55 56 std::string session_id; 57 std::string refresh_url; 58 Scope scope; 59 std::vector<Credential> credentials; 60 }; 61 62 } // namespace net::device_bound_sessions 63 64 #endif // NET_DEVICE_BOUND_SESSIONS_SESSION_PARAMS_H_ 65