Skip to content

Commit 265947c

Browse files
committed
readme
1 parent 2b9d5bd commit 265947c

3 files changed

Lines changed: 84 additions & 3 deletions

File tree

README.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,82 @@
11
# Argon
22

3-
todo make this an api mod?
3+
API for authenticating Geometry Dash accounts. Made by creators of Globed, and is completely free and open-source, including the [server](https://github.com/GlobedGD/argon-server). Can be selfhosted (for example for a GDPS), but we provide our server at https://argon.globed.dev and this library uses it by default.
4+
5+
Benefits compared to some of the other auth APIs (Globed, DashAuth, GDAuth):
6+
7+
* Does not send your GJP or password to any 3rd party server
8+
* Tokens are stored globally, meaning that authentication is done only once even if the user has multiple mods installed that use Argon
9+
* Smooth UX for switching accounts (will not try to use or overwrite the token of the other account)
10+
* Our official instance is whitelisted by RobTop, which means authentication is faster and more reliable against IP blocks
11+
* Challenges don't entirely rely on the IP address, but are still secured in other ways, preventing errors if the user has a weird ISP
12+
* Ability to retrieve user's username without making requests to the GD server (with just their token)
13+
* (TODO, not done yet) Automatic troubleshooter for figuring out the cause of auth issues (for example invalid session or too many sent messages)
14+
15+
## Usage (client-side)
16+
17+
First, add Argon to the `CMakeLists.txt` of your mod:
18+
19+
```cmake
20+
CPMAddPackage("gh:GlobedGD/argon@1.0.0")
21+
target_link_libraries(${PROJECT_NAME} argon)
22+
```
23+
24+
Complete example of how to perform authentication:
25+
26+
```cpp
27+
#include <argon/argon.hpp>
28+
#include <Geode/Geode.hpp>
29+
30+
using namespace geode::prelude;
31+
32+
33+
$on_mod(Loaded) {
34+
// Do note the authentication is asynchronous, do NOT pass anything in the lambda captures to these callbacks,
35+
// unless you are certain that object will continue to exist.
36+
37+
auto res = argon::startAuth([](Result<std::string> res) {
38+
// This callback is called on the main thread once the authentication completes.
39+
// Note that if the authtoken is already stored in user's cache,
40+
// this function will be called immediately!
41+
42+
if (!res) {
43+
log::warn("Auth failed: {}", res.unwrapErr());
44+
return;
45+
}
46+
47+
auto token = std::move(res).unwrap();
48+
49+
// Now you have an authtoken that you can use to verify the user!
50+
// Send this to your mod's server, which should verify it with the Argon server to ensure it is valid.
51+
52+
log::debug("Token: {}", token);
53+
}, [](argon::AuthProgress progress) {
54+
// This callback is called whenever the client moves to the next step of authentication
55+
56+
log::info("Auth progress: {}", argon::authProgressToString(progress));
57+
});
58+
59+
if (!res) {
60+
log::warn("Failed to start auth attempt: {}", res.unwrapErr());
61+
}
62+
}
63+
```
64+
65+
If running into token validation issues, tokens can be cleared to attempt authentication again:
66+
67+
```cpp
68+
argon::clearToken();
69+
```
70+
71+
If using a custom server, the URL can be set like so:
72+
73+
```cpp
74+
// this unwrap is safe as long as *no* auth requests are currently running
75+
argon::setServerUrl("http://localhost:4341").unwrap();
76+
```
77+
78+
Few more functions are provided for managing tokens and for ensuring thread safety, you can find out about the rest of the functionality by reading the docstrings in `include/argon/argon.hpp` header.
79+
80+
## Usage (server-side)
81+
82+
After the user has generated an authtoken, they should send it to your server, which in turn will send the token to the Argon server for validation. Server-side API has its own [documentation](https://github.com/GlobedGD/argon-server/blob/main/docs/server-api.md) which describes in detail how to use it.

include/argon/argon.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace argon {
2424
RetryingVerify,
2525
};
2626

27+
// Converts the `AuthProgress` enum to a human readable string,
28+
// e.g. "Requesting challenge", "Solving challenge"
2729
std::string authProgressToString(AuthProgress progress);
2830

2931
using AuthCallback = std::function<void(geode::Result<std::string>)>;
@@ -33,7 +35,7 @@ namespace argon {
3335
// Collects the account data of the currently logged in user. Not thread-safe.
3436
AccountData getGameAccountData();
3537

36-
// Set the URL of the used Argon server
38+
// Set the URL of the used Argon server, not thread-safe.
3739
geode::Result<> setServerUrl(std::string url);
3840

3941
// Initializes the config lock structure for interoperability between other mods using Argon.

src/state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Stage1ResponseData {
2929
};
3030

3131
ArgonState::ArgonState() {
32-
(void) this->setServerUrl("https://argon.dankmeme.dev").unwrap();
32+
(void) this->setServerUrl("https://argon.globed.dev").unwrap();
3333
}
3434

3535
ArgonState::~ArgonState() {}

0 commit comments

Comments
 (0)