Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Name the console's machine when signing in to Steam

Leonardo Lobatoc5d0ff8d8d0e
diff --git a/fixtures/steam/auth/README.md b/fixtures/steam/auth/README.md
index df39c6a..fc51b16 100644
--- a/fixtures/steam/auth/README.md
+++ b/fixtures/steam/auth/README.md
@@ -4,4 +4,4 @@ These protobuf frames contain deterministic synthetic values only. They were enc
The `.textproto` files are readable descriptions of the matching `.pb` frames. They are not captured service traffic and contain no real account IDs, request IDs, tokens, QR challenges, guard data, or endpoints.
-The credential sign-in frames (`rsa_key_*`, `credentials_*`, `guard_code_request`) were encoded from their `.textproto` files with `protoc --encode` against `../proto/steammessages_auth.steamclient.proto` (protoc 35.1). The same command reproduces `begin_request.pb` byte for byte.
+The credential sign-in frames (`rsa_key_*`, `credentials_*`, `guard_code_request`) were encoded from their `.textproto` files with `protoc --encode` against `../proto/steammessages_auth.steamclient.proto` (protoc 35.1). `begin_request.pb`, which now carries the device fields and a synthetic machine ID, is encoded the same way.
diff --git a/fixtures/steam/auth/begin_request.pb b/fixtures/steam/auth/begin_request.pb
index 5f24d67..f531f28 100644
Binary files a/fixtures/steam/auth/begin_request.pb and b/fixtures/steam/auth/begin_request.pb differ
diff --git a/fixtures/steam/auth/begin_request.textproto b/fixtures/steam/auth/begin_request.textproto
index 65713c2..9d02cec 100644
--- a/fixtures/steam/auth/begin_request.textproto
+++ b/fixtures/steam/auth/begin_request.textproto
@@ -1,6 +1,9 @@
+device_friendly_name: "Playden Synthetic Device"
+platform_type: k_EAuthTokenPlatformType_SteamClient
device_details {
device_friendly_name: "Playden Synthetic Device"
platform_type: k_EAuthTokenPlatformType_SteamClient
os_type: 0
+ machine_id: "\000MessageObject\000\010\010"
}
website_id: "Client"
diff --git a/fixtures/steam/proto/auth_fixture_manifest.json b/fixtures/steam/proto/auth_fixture_manifest.json
index 337475a..297e5d3 100644
--- a/fixtures/steam/proto/auth_fixture_manifest.json
+++ b/fixtures/steam/proto/auth_fixture_manifest.json
@@ -1,7 +1,7 @@
{
"data_policy": "All tokens, account names, IDs, request bytes, URLs and guard data are deterministic synthetic values. No real account data is included.",
"fixture_sources_sha256": {
- "begin_request.textproto": "414cdea68cb63005007898d7fefa95246b692306289d05471d09a2b44ad486bf",
+ "begin_request.textproto": "17db337254ba36fca7775518114cb4a7573c88c12fedb8107ed4e39b0847984a",
"begin_response.textproto": "31948bad47524918476c8843287d34da610b31b149095eaa5c705520c77f8149",
"poll_pending_response.textproto": "cb44c94e45eb9c3ee3d11e172f4415ce21503f581c9633afbcf76fc383e08519",
"poll_request.textproto": "f99423e283804b642de603749198574628f4a7298e44b4364d03642843c43229",
@@ -10,7 +10,7 @@
"renew_response.textproto": "c6733d98720e99c9e17616a4e4bad95aab05e2f3b8ed13525a9cab406bb2dfe5"
},
"fixtures_sha256": {
- "begin_request.pb": "060040dfdbfdd78849fa30502f19f6974d2c8a2f57359bd1ff39be31ca9158ca",
+ "begin_request.pb": "880faf3a018f255c580c348605f8d0ff1668e0b452b5b1a4410e8cb309ae924b",
"begin_response.pb": "3b8d874101cf1a4f2e3e7c28adb45d495514a77879bd7da1a1ff5decfe842a8a",
"poll_pending_response.pb": "27aebe920b830a0609b184aed1dea59b47cc4e22ce07da953652d21f1fabe02b",
"poll_request.pb": "66b5ae5274786d5413c3a0492d75de46d3620c452a0aa78cc1f87395baf088e1",
diff --git a/src/homebrew/host.cpp b/src/homebrew/host.cpp
index 9144f9c..5dcd3f2 100644
--- a/src/homebrew/host.cpp
+++ b/src/homebrew/host.cpp
@@ -482,6 +482,9 @@ int main(int argc, char** argv) {
auth_storage = std::make_unique<playden::Storage>(options->data_directory.string());
auth_cm = std::make_unique<playden::steam::CmClient>(PLAYDEN_HOMEBREW_CA_BUNDLE, *auth_storage);
auth = std::make_unique<playden::steam::AuthClient>(PLAYDEN_HOMEBREW_CA_BUNDLE);
+ auth->SetMachineId([storage = auth_storage.get()] {
+ return playden::steam::MakeDeviceIdentity(playden::steam::LoadOrCreateDeviceSeed(*storage)).machine_id;
+ });
auth->SetCmRenewal([cm = auth_cm.get()](const playden::StoredSession& stored, const std::atomic<bool>& cancel) {
return playden::steam::RenewThroughCm(*cm, stored, cancel);
});
@@ -492,6 +495,10 @@ int main(int argc, char** argv) {
std::snprintf(line, sizeof(line), "auth_failure method=%s http=%ld eresult=%d", method, http_status, eresult);
playden::app::AppendLogLine(log_directory, "auth.log", line);
});
+ auth->SetSignInReport([log_directory](long long persistence, std::uint64_t lifetime_seconds) {
+ playden::app::AppendLogLine(log_directory, "auth.log", "signed_in persistence=" + std::to_string(persistence) +
+ " lifetime_days=" + std::to_string(lifetime_seconds / 86400));
+ });
// "Stay signed in" is known before the controller restores the session.
const bool stay_signed_in = playden::PreferencesStore(*auth_storage).Load().preferences.steam_stay_signed_in;
session_vault = std::make_unique<playden::SessionVault>(stay_signed_in);
diff --git a/src/homebrew/ps5.cpp b/src/homebrew/ps5.cpp
index d47d286..48e3c87 100644
--- a/src/homebrew/ps5.cpp
+++ b/src/homebrew/ps5.cpp
@@ -293,6 +293,16 @@ int main() {
auth_cm.SetOwner("auth");
auth_cm.SetSharedSession(steam_cm);
playden::steam::AuthClient auth(paths.trust_store);
+ // A sign-in names the machine the CM logons come from, in case Steam ties the token to it (saved sign-ins
+ // died about a day later without it).
+ auth.SetMachineId([&auth_storage] {
+ return playden::steam::MakeDeviceIdentity(playden::steam::LoadOrCreateDeviceSeed(auth_storage)).machine_id;
+ });
+ // Whether Steam kept the new session (its "per" claim) and how long the token says it lasts.
+ auth.SetSignInReport([](long long persistence, std::uint64_t lifetime_seconds) {
+ playden::app::AppendLogLine(log_root, "auth.log", "signed_in persistence=" + std::to_string(persistence) +
+ " lifetime_days=" + std::to_string(lifetime_seconds / 86400));
+ });
auth.SetCmRenewal([&auth_cm](const playden::StoredSession& stored, const std::atomic<bool>& cancel) {
return playden::steam::RenewThroughCm(auth_cm, stored, cancel);
});
diff --git a/src/steam/backend/auth_client.cpp b/src/steam/backend/auth_client.cpp
index 4dcf653..64c5c7f 100644
--- a/src/steam/backend/auth_client.cpp
+++ b/src/steam/backend/auth_client.cpp
@@ -187,6 +187,7 @@ AuthResult AuthClient::AuthenticateQr(const std::atomic<bool>& cancel,
const auto started = hooks_.monotonic_ms();
auth::BeginAuthSessionViaQrRequest begin;
begin.device_details.device_friendly_name = "Playden (PS5)";
+ if (hooks_.machine_id) begin.device_details.machine_id = hooks_.machine_id();
std::vector<std::uint8_t> request, response;
if (!auth::Encode(begin, &request).ok()) return Failure(AuthError::kProtocol);
auto error = Post("BeginAuthSessionViaQR", request, cancel, Remaining(started,hooks_), false, &response);
@@ -241,16 +242,23 @@ AuthResult AuthClient::Approved(auth::PollAuthSessionStatusResponse approval, st
const auto now = hooks_.unix_seconds();
if (!claims || claims->expires_at_unix_seconds <= now || !AccountNameValid(approval.account_name))
return Failure(AuthError::kProtocol);
+ // Reported once the sign-in succeeds: the refresh token's own claims, not a promise that Steam keeps it.
+ auto signed_in = [&, issued = claims->issued_at_unix_seconds ? claims->issued_at_unix_seconds : now,
+ expires = claims->expires_at_unix_seconds, persistence = claims->persistence](AuthResult result) {
+ if (result.error == AuthError::kNone && hooks_.signed_in)
+ hooks_.signed_in(persistence ? static_cast<long long>(*persistence) : -1, expires > issued ? expires - issued : 0);
+ return result;
+ };
StoredSession stored{claims->steam_id, approval.account_name, std::move(approval.refresh_token),
std::move(approval.access_token), std::nullopt};
if (stored.access_token.empty()) {
auto renewed = Renew(stored,cancel,Remaining(started,hooks_,lifetime_ms),false);
if (cancel.load()) return Failure(AuthError::kCanceled);
if (!Remaining(started,hooks_,lifetime_ms)) return Failure(AuthError::kExpired);
- return renewed;
+ return signed_in(std::move(renewed));
}
if (!ValidToken(stored.access_token,stored.steam_id,now)) return Failure(AuthError::kProtocol);
- return {AuthError::kNone,std::move(stored)};
+ return signed_in({AuthError::kNone,std::move(stored)});
}
AuthResult AuthClient::AuthenticateCredentials(Credentials& credentials, const std::atomic<bool>& cancel,
@@ -279,6 +287,7 @@ AuthResult AuthClient::AuthenticateCredentials(Credentials& credentials, const s
if (!auth::Decode(response, &key).ok() || !key.timestamp) return Failure(AuthError::kProtocol);
auth::BeginAuthSessionViaCredentialsRequest begin;
begin.device_details.device_friendly_name = "Playden (PS5)";
+ if (hooks_.machine_id) begin.device_details.machine_id = hooks_.machine_id();
begin.account_name = credentials.account_name;
begin.encryption_timestamp = key.timestamp;
auto encrypted = EncryptPassword(key.publickey_mod, key.publickey_exp, credentials.password);
diff --git a/src/steam/backend/auth_client.h b/src/steam/backend/auth_client.h
index af1525d..7a7837f 100644
--- a/src/steam/backend/auth_client.h
+++ b/src/steam/backend/auth_client.h
@@ -24,6 +24,11 @@ struct AuthClientHooks {
// Optional report of a successful restore: which path (stored, web, cm), and the refresh token's
// fingerprint before and after (they differ when Steam rotated it).
std::function<void(const char* path, const std::string& before, const std::string& after)> restored;
+ // Optional: the machine ID the CM logon sends, so a sign-in names the same device (empty: none sent).
+ std::function<std::vector<std::uint8_t>()> machine_id;
+ // Optional report of a new sign-in's token claims: Steam's persistence flag (-1: none) and the token's
+ // lifetime in seconds. Never the token or the account.
+ std::function<void(long long persistence, std::uint64_t lifetime_seconds)> signed_in;
};
class AuthClient final : public AuthBackend {
@@ -38,6 +43,12 @@ class AuthClient final : public AuthBackend {
void SetRestoreReport(std::function<void(const char*, const std::string&, const std::string&)> report) {
hooks_.restored = std::move(report);
}
+ void SetMachineId(std::function<std::vector<std::uint8_t>()> machine_id) {
+ hooks_.machine_id = std::move(machine_id);
+ }
+ void SetSignInReport(std::function<void(long long, std::uint64_t)> report) {
+ hooks_.signed_in = std::move(report);
+ }
void SetCmRenewal(std::function<AuthResult(const StoredSession&, const std::atomic<bool>&)> renew) {
hooks_.cm_renew = std::move(renew);
}
diff --git a/src/steam/backend/auth_messages.cpp b/src/steam/backend/auth_messages.cpp
index 295120d..174e752 100644
--- a/src/steam/backend/auth_messages.cpp
+++ b/src/steam/backend/auth_messages.cpp
@@ -32,7 +32,8 @@ bool EncodeDeviceDetails(const DeviceDetails& message, Writer* writer) {
return writer->AddString(1, message.device_friendly_name) &&
writer->AddVarint(2, static_cast<std::uint64_t>(message.platform_type)) &&
writer->AddVarint(
- 3, static_cast<std::uint64_t>(static_cast<std::int64_t>(message.os_type)));
+ 3, static_cast<std::uint64_t>(static_cast<std::int64_t>(message.os_type))) &&
+ (message.machine_id.empty() || writer->AddBytes(6, message.machine_id));
}
Status DecodeAllowedConfirmation(Reader* reader,
@@ -63,6 +64,8 @@ Status Encode(const BeginAuthSessionViaQrRequest& message,
Writer device;
EncodeDeviceDetails(message.device_details, &device);
Writer writer;
+ writer.AddString(1, message.device_details.device_friendly_name);
+ writer.AddVarint(2, static_cast<std::uint64_t>(message.device_details.platform_type));
writer.AddMessage(3, device);
writer.AddString(4, message.website_id);
return WriterStatus(writer, output);
diff --git a/src/steam/backend/auth_messages.h b/src/steam/backend/auth_messages.h
index dc56128..6bbb61a 100644
--- a/src/steam/backend/auth_messages.h
+++ b/src/steam/backend/auth_messages.h
@@ -42,8 +42,11 @@ struct DeviceDetails {
std::string device_friendly_name;
PlatformType platform_type = PlatformType::kSteamClient;
std::int32_t os_type = 0;
+ // The machine ID the CM logon sends (binary KeyValues), so the sign-in and the logons name one machine. Empty: not sent.
+ std::vector<std::uint8_t> machine_id;
};
+// The device's friendly name and platform are also sent at the top level, like the credentials request.
struct BeginAuthSessionViaQrRequest {
DeviceDetails device_details;
std::string website_id = "Client";
diff --git a/src/steam/backend/cm_client.cpp b/src/steam/backend/cm_client.cpp
index 51c71a7..ed2ffbe 100644
--- a/src/steam/backend/cm_client.cpp
+++ b/src/steam/backend/cm_client.cpp
@@ -13,6 +13,7 @@
#include <chrono>
#include <condition_variable>
#include <functional>
+#include <map>
#include <mutex>
#include <set>
#include <thread>
@@ -184,6 +185,10 @@ std::string LoadOrCreateDeviceSeed(const Storage& storage) {
text.pop_back();
if (ValidSeed(text)) return text;
}
+ // A seed that could not be saved is still this run's identity: the sign-in and the CM logons that share this
+ // storage must name the same machine.
+ static std::map<const Storage*, std::string> unsaved;
+ if (const auto kept = unsaved.find(&storage); kept != unsaved.end()) return kept->second;
// A per-install value only has to differ from other installs, so hash several local sources
// rather than depend on an entropy device the console may not provide.
const auto wall = std::chrono::system_clock::now().time_since_epoch().count();
@@ -196,8 +201,9 @@ std::string LoadOrCreateDeviceSeed(const Storage& storage) {
unsigned char digest[32] = {};
mbedtls_sha256(reinterpret_cast<const unsigned char*>(input.data()), input.size(), digest, 0);
const std::string seed = Hex(digest, 16);
- if (storage.EnsureRootDirectory().ok())
- (void)storage.WriteAtomicPrivate(kDeviceSeedFile, Bytes(seed.begin(), seed.end()));
+ if (!storage.EnsureRootDirectory().ok() ||
+ !storage.WriteAtomicPrivate(kDeviceSeedFile, Bytes(seed.begin(), seed.end())).ok())
+ unsaved[&storage] = seed;
return seed;
}
diff --git a/src/steam/backend/token_claims.cpp b/src/steam/backend/token_claims.cpp
index a04d81e..4d20883 100644
--- a/src/steam/backend/token_claims.cpp
+++ b/src/steam/backend/token_claims.cpp
@@ -66,7 +66,12 @@ std::optional<TokenClaims> InspectTokenClaims(std::string_view token) {
}
const auto expires = expiration->AsUint64();
if (steam_id == 0 || !expires || *expires == 0) return std::nullopt;
- return TokenClaims{steam_id, *expires};
+ TokenClaims claims{steam_id, *expires};
+ if (const json::Value* issued = root->Find("iat"); issued && issued->is_number())
+ claims.issued_at_unix_seconds = issued->AsUint64().value_or(0);
+ if (const json::Value* persistence = root->Find("per"); persistence && persistence->is_number())
+ claims.persistence = persistence->AsUint64();
+ return claims;
}
} // namespace playden::steam
diff --git a/src/steam/backend/token_claims.h b/src/steam/backend/token_claims.h
index 25915d3..8ce3ba9 100644
--- a/src/steam/backend/token_claims.h
+++ b/src/steam/backend/token_claims.h
@@ -9,6 +9,9 @@ namespace playden::steam {
struct TokenClaims {
std::uint64_t steam_id = 0;
std::uint64_t expires_at_unix_seconds = 0;
+ std::uint64_t issued_at_unix_seconds = 0; // 0: no "iat" claim
+ // Steam's "per" claim: 1 for a session kept across restarts, 0 for one that is not. Nothing: no claim.
+ std::optional<std::uint64_t> persistence;
};
// Inspects local JWT claims only. This does not validate a JWT signature or establish trust.
diff --git a/tests/auth_client_test.cpp b/tests/auth_client_test.cpp
index ab856a2..ba2e774 100644
--- a/tests/auth_client_test.cpp
+++ b/tests/auth_client_test.cpp
@@ -94,6 +94,56 @@ void QrSuccessAndReplacement() {
assert(std::string(f.requests[2].body.begin(), f.requests[2].body.end()) ==
"input_protobuf_encoded=CMgDEhFzeW50aGV0aWMtcmVxdWVzdA%3D%3D");
}
+// The form body Playden posts for an encoded message: standard base64, then URL-escaped.
+std::string FormBody(const std::vector<std::uint8_t>& bytes) {
+ const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ std::string b64;
+ for (std::size_t at = 0; at < bytes.size(); at += 3) {
+ const unsigned n = bytes[at] << 16 | (at + 1 < bytes.size() ? bytes[at + 1] << 8 : 0) |
+ (at + 2 < bytes.size() ? bytes[at + 2] : 0);
+ b64 += alphabet[n >> 18 & 63]; b64 += alphabet[n >> 12 & 63];
+ b64 += at + 1 < bytes.size() ? alphabet[n >> 6 & 63] : '=';
+ b64 += at + 2 < bytes.size() ? alphabet[n & 63] : '=';
+ }
+ std::string body = "input_protobuf_encoded=";
+ for (char c : b64) body += c == '+' ? "%2B" : c == '/' ? "%2F" : c == '=' ? "%3D" : std::string(1, c);
+ return body;
+}
+// A sign-in names the CM logon's machine and reports the new token's persistence and lifetime.
+void QrNamesTheMachineAndReportsClaims() {
+ const std::string refresh = B64("{\"alg\":\"RS256\"}") + "." +
+ B64("{\"sub\":\"76561198000000001\",\"exp\":1918144000,\"iat\":1900000000,\"per\":1}") + "." + B64("sig");
+ Fixture f; f.replies.push_back(Begin()); f.replies.push_back(Success(refresh));
+ auto hooks = f.Hooks();
+ int machine_calls = 0;
+ hooks.machine_id = [&machine_calls] { ++machine_calls; return std::vector<std::uint8_t>{0x00, 0xFE, 0x08}; };
+ long long persistence = -2; std::uint64_t lifetime = 0;
+ hooks.signed_in = [&](long long per, std::uint64_t seconds) { persistence = per; lifetime = seconds; };
+ AuthClient client(hooks);
+ assert(client.AuthenticateQr(f.cancel, f.Callback()).error == AuthError::kNone);
+ auth::BeginAuthSessionViaQrRequest expected;
+ expected.device_details.device_friendly_name = "Playden (PS5)";
+ expected.device_details.machine_id = {0x00, 0xFE, 0x08};
+ std::vector<std::uint8_t> encoded;
+ assert(auth::Encode(expected, &encoded).ok());
+ assert(machine_calls == 1);
+ assert(std::string(f.requests[0].body.begin(), f.requests[0].body.end()) == FormBody(encoded));
+ assert(persistence == 1 && lifetime == 18144000);
+ // A token without the claims reports none, and the lifetime from the sign-in time.
+ Fixture g; g.replies.push_back(Begin()); g.replies.push_back(Success());
+ auto plain = g.Hooks();
+ plain.signed_in = [&](long long per, std::uint64_t seconds) { persistence = per; lifetime = seconds; };
+ AuthClient without(plain);
+ assert(without.AuthenticateQr(g.cancel, g.Callback()).error == AuthError::kNone);
+ assert(persistence == -1 && lifetime == 2000000000ULL - 1900000000ULL);
+ // A sign-in that fails after the refresh token arrives (a bad access token) is not reported.
+ persistence = -2;
+ Fixture h; h.replies.push_back(Begin()); h.replies.push_back(Success(refresh, Token("76561198000000002")));
+ auto failing = h.Hooks();
+ failing.signed_in = [&](long long per, std::uint64_t) { persistence = per; };
+ AuthClient refused(failing);
+ assert(refused.AuthenticateQr(h.cancel, h.Callback()).error == AuthError::kProtocol && persistence == -2);
+}
void FailuresAndDeadline() {
{
Fixture f; f.cancel = true; AuthClient c(f.Hooks());
@@ -336,8 +386,11 @@ struct Guard {
};
}
};
-AuthResult SignIn(Fixture& f, Guard& g, std::string* password_after = nullptr) {
- AuthClient c(f.Hooks());
+AuthResult SignIn(Fixture& f, Guard& g, std::string* password_after = nullptr,
+ std::vector<std::uint8_t> machine_id = {}) {
+ auto hooks = f.Hooks();
+ if (!machine_id.empty()) hooks.machine_id = [machine_id] { return machine_id; };
+ AuthClient c(hooks);
playden::steam::Credentials credentials{"synthetic_account", "hunter2-synthetic"};
auto r = c.AuthenticateCredentials(credentials, f.cancel, g.Prompt(), g.Code());
if (password_after) *password_after = credentials.password;
@@ -359,6 +412,11 @@ void CredentialsWithoutGuard() {
begin.url == "https://api.steampowered.com/IAuthenticationService/BeginAuthSessionViaCredentials/v1/");
const auto sent = Sent(begin);
assert(sent.find("synthetic_account") != std::string::npos && sent.find("Playden (PS5)") != std::string::npos);
+ // The password sign-in names the CM logon's machine too: device details field 6.
+ Fixture named; Guard named_guard;
+ named.replies = {Key(), BeginCredentials({}), Success()};
+ assert(SignIn(named, named_guard, nullptr, {0x00, 'M', 'I', 'D', 0x08}).error == AuthError::kNone);
+ assert(Sent(named.requests[1]).find(std::string("\x32\x05\x00MID\x08", 7)) != std::string::npos);
// Only the encrypted password goes out.
for (const auto& request : f.requests) {
assert(Sent(request).find("hunter2-synthetic") == std::string::npos);
@@ -502,6 +560,6 @@ void CredentialsCancelAndDeadline() {
int main() {
CredentialsWithoutGuard(); CredentialsEmailCode(); CredentialsAuthenticatorCode(); CredentialsApproval();
CredentialsFailures(); CredentialsCancelAndDeadline();
- QrSuccessAndReplacement(); FailuresAndDeadline(); HeadersAndTokens(); DeadlineAndCancellationEdges(); Restoration(); AccountNames(); FailedReplacementKeepsSavedSession();
+ QrSuccessAndReplacement(); QrNamesTheMachineAndReportsClaims(); FailuresAndDeadline(); HeadersAndTokens(); DeadlineAndCancellationEdges(); Restoration(); AccountNames(); FailedReplacementKeepsSavedSession();
std::cout << "auth_client_test passed\n";
}
diff --git a/tests/auth_messages_test.cpp b/tests/auth_messages_test.cpp
index 9e5aef0..f9a183a 100644
--- a/tests/auth_messages_test.cpp
+++ b/tests/auth_messages_test.cpp
@@ -33,6 +33,7 @@ void TestGoldenRequests(const std::string& root) {
begin.device_details.device_friendly_name = "Playden Synthetic Device";
begin.device_details.platform_type = auth::PlatformType::kSteamClient;
begin.device_details.os_type = 0;
+ begin.device_details.machine_id = {0x00, 'M', 'e', 's', 's', 'a', 'g', 'e', 'O', 'b', 'j', 'e', 'c', 't', 0x00, 0x08, 0x08};
begin.website_id = "Client";
ExpectGoldenEncode(root + "/begin_request.pb", begin);
diff --git a/tests/cm_client_test.cpp b/tests/cm_client_test.cpp
index 38ee71e..5b881e5 100644
--- a/tests/cm_client_test.cpp
+++ b/tests/cm_client_test.cpp
@@ -805,6 +805,12 @@ void DeviceSeedPersistsPerInstall() {
assert(MakeDeviceIdentity(first).machine_id == MakeDeviceIdentity(second).machine_id);
assert(MakeDeviceIdentity(first).login_id != MakeDeviceIdentity(kSeed).login_id);
std::filesystem::remove_all(root);
+ // A seed that cannot be saved (the root's parent is missing) is still the same for the rest of the run, so a
+ // sign-in and the CM logons sharing the storage name one machine.
+ Storage unwritable((root / "missing-parent" / "root").string());
+ const auto unsaved = LoadOrCreateDeviceSeed(unwritable);
+ assert(unsaved.size() == 32 && LoadOrCreateDeviceSeed(unwritable) == unsaved);
+ assert(!std::filesystem::exists(root));
}
} // namespace
diff --git a/tests/token_claims_test.cpp b/tests/token_claims_test.cpp
index 310c525..473fc3f 100644
--- a/tests/token_claims_test.cpp
+++ b/tests/token_claims_test.cpp
@@ -26,6 +26,12 @@ int main() {
assert(claims && claims->steam_id == 76561198012345678ULL && claims->expires_at_unix_seconds == 4102444800ULL);
claims = playden::steam::InspectTokenClaims(Token(R"({"sub":"18446744073709551615","exp":18446744073709551615})"));
assert(claims && claims->steam_id == UINT64_MAX && claims->expires_at_unix_seconds == UINT64_MAX);
+ assert(claims->issued_at_unix_seconds == 0 && !claims->persistence);
+ // Steam's issue time and persistence flag, when present.
+ claims = playden::steam::InspectTokenClaims(Token(R"({"sub":"1","exp":4102444800,"iat":4000000000,"per":0})"));
+ assert(claims && claims->issued_at_unix_seconds == 4000000000ULL && claims->persistence == 0ULL);
+ claims = playden::steam::InspectTokenClaims(Token(R"({"sub":"1","exp":5,"per":"1","iat":"2"})"));
+ assert(claims && claims->issued_at_unix_seconds == 0 && !claims->persistence);
assert(!playden::steam::InspectTokenClaims("AA.AA"));
assert(!playden::steam::InspectTokenClaims("AA.AA.AA.AA"));