2021-04-13 17:01:20 -04:00
|
|
|
/*
|
2023-02-24 11:51:56 -05:00
|
|
|
* Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
|
2021-04-13 17:01:20 -04:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-13 17:01:20 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2023-02-24 11:51:56 -05:00
|
|
|
#include <AK/Time.h>
|
2022-10-15 13:54:54 +02:00
|
|
|
#include <LibIPC/Forward.h>
|
2021-04-13 17:01:20 -04:00
|
|
|
|
|
|
|
|
namespace Web::Cookie {
|
|
|
|
|
|
2022-10-21 13:00:04 +02:00
|
|
|
enum class SameSite {
|
|
|
|
|
Default,
|
|
|
|
|
None,
|
|
|
|
|
Strict,
|
|
|
|
|
Lax
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-13 17:30:41 -04:00
|
|
|
enum class Source {
|
|
|
|
|
NonHttp,
|
|
|
|
|
Http,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-13 17:01:20 -04:00
|
|
|
struct Cookie {
|
2023-02-24 11:51:56 -05:00
|
|
|
DeprecatedString creation_time_to_string() const;
|
|
|
|
|
DeprecatedString last_access_time_to_string() const;
|
|
|
|
|
DeprecatedString expiry_time_to_string() const;
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString name;
|
|
|
|
|
DeprecatedString value;
|
2022-10-21 13:00:04 +02:00
|
|
|
SameSite same_site;
|
2023-02-24 11:51:56 -05:00
|
|
|
Time creation_time {};
|
|
|
|
|
Time last_access_time {};
|
|
|
|
|
Time expiry_time {};
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString domain {};
|
|
|
|
|
DeprecatedString path {};
|
2021-04-13 17:01:20 -04:00
|
|
|
bool secure { false };
|
|
|
|
|
bool http_only { false };
|
|
|
|
|
bool host_only { false };
|
|
|
|
|
bool persistent { false };
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-21 13:00:04 +02:00
|
|
|
StringView same_site_to_string(SameSite same_site_mode);
|
2022-11-11 10:30:26 -05:00
|
|
|
SameSite same_site_from_string(StringView same_site_mode);
|
2022-10-21 13:00:04 +02:00
|
|
|
|
2021-04-13 17:01:20 -04:00
|
|
|
}
|
2022-10-15 13:54:54 +02:00
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
2022-11-15 11:24:59 -05:00
|
|
|
template<>
|
2023-01-01 23:37:35 -05:00
|
|
|
ErrorOr<void> encode(Encoder&, Web::Cookie::Cookie const&);
|
2022-11-15 11:24:59 -05:00
|
|
|
|
|
|
|
|
template<>
|
2022-12-22 20:40:33 -05:00
|
|
|
ErrorOr<Web::Cookie::Cookie> decode(Decoder&);
|
2022-10-15 13:54:54 +02:00
|
|
|
|
|
|
|
|
}
|