atlas-auth 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,349 @@
1
+ /*
2
+ * Atlas.c.h - plain C header for the Atlas.dll ABI. Windows x64 only.
3
+ *
4
+ * This describes the extern "C" DLL surface produced by AtlasExports.cpp.
5
+ * Not to be confused with the C++ header (Atlas.h) - that one exposes the
6
+ * namespaced C++ API for static-library consumers. Non-C++ bindings
7
+ * (Python ctypes, Rust bindgen, Zig, cffi) can't parse the C++ header;
8
+ * this is the one they can.
9
+ *
10
+ * Every extern here maps 1:1 to a __declspec(dllexport) in AtlasExports.cpp.
11
+ * All calls are __cdecl. Status codes are stable and add-only.
12
+ *
13
+ * Header targets DLL surface v1.0.0. Call Atlas_Version() at runtime to
14
+ * read the loaded DLL's actual version.
15
+ */
16
+
17
+ #ifndef ATLAS_C_H
18
+ #define ATLAS_C_H
19
+
20
+ #include <stddef.h>
21
+ #include <stdint.h>
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /* -- status codes ---------------------------------------------------------- */
28
+ /* Stable numeric contract - do not renumber. Add-only. */
29
+ #define ATLAS_OK 0
30
+ #define ATLAS_ERR_NOT_STARTED 1
31
+ #define ATLAS_ERR_NO_API_KEY 2
32
+ #define ATLAS_ERR_LOGIN_FAILED 3
33
+ #define ATLAS_ERR_NOT_AUTHED 4
34
+ #define ATLAS_ERR_BAD_ARG 5
35
+ #define ATLAS_ERR_BUFFER_TOO_SMALL 6
36
+ #define ATLAS_ERR_SERVER 7
37
+ #define ATLAS_ERR_INTERNAL 8
38
+ /* Account-mode: server wants an 8-digit verification code from the user.
39
+ * The SDK is holding the challenge until Atlas_SubmitVerify() is called. */
40
+ #define ATLAS_ERR_NEEDS_VERIFY 10
41
+
42
+ /* -- DLL calling convention ------------------------------------------------ */
43
+ #if defined(_WIN32) || defined(_WIN64)
44
+ #define ATLAS_CALL __cdecl
45
+ #if defined(ATLAS_STATIC)
46
+ #define ATLAS_API
47
+ #elif defined(ATLAS_BUILD_DLL)
48
+ #define ATLAS_API __declspec(dllexport)
49
+ #else
50
+ #define ATLAS_API __declspec(dllimport)
51
+ #endif
52
+ #else
53
+ #define ATLAS_CALL
54
+ #define ATLAS_API
55
+ #endif
56
+
57
+ /* -- lifecycle ------------------------------------------------------------- */
58
+
59
+ /* Set the API key. Must be called BEFORE Atlas_Startup().
60
+ * Returns: ATLAS_OK, ATLAS_ERR_BAD_ARG. */
61
+ ATLAS_API int ATLAS_CALL Atlas_SetApiKey(const char* api_key);
62
+
63
+ /* -- apphash overrides ----------------------------------------------------
64
+ * The DLL's default apphash is SHA-256 of GetModuleFileNameA(NULL) - under
65
+ * a non-C++ host that's node.exe / dotnet.exe / python.exe, NOT the file
66
+ * that identifies the developer's application. These overrides let a
67
+ * binding pin the apphash to something meaningful.
68
+ *
69
+ * Both are one-shot per process AND lock after Atlas_Startup(). Post-init
70
+ * writes return ATLAS_ERR_BAD_ARG. See AppHash.md for the threat model.
71
+ */
72
+
73
+ /* Override the file whose SHA-256 becomes the apphash. Path validated
74
+ * (non-empty, <=32767 chars); file is read at server-call time.
75
+ * Returns: ATLAS_OK, ATLAS_ERR_BAD_ARG. */
76
+ ATLAS_API int ATLAS_CALL Atlas_SetAppHashPath(const char* path);
77
+
78
+ /* Set the apphash directly. Input MUST be lowercase-hex SHA-256:
79
+ * exactly 64 chars, [0-9a-f] only. Empty / uppercase / any other input
80
+ * rejected - no way to nullify the hash and bypass server whitelisting.
81
+ * Returns: ATLAS_OK, ATLAS_ERR_BAD_ARG. */
82
+ ATLAS_API int ATLAS_CALL Atlas_SetAppHash(const char* hex64);
83
+
84
+ /* Read the apphash that WILL be sent to the server on the next request.
85
+ * Callable pre or post Startup. Size-query pattern. Empty string if the
86
+ * source file couldn't be read. */
87
+ ATLAS_API int ATLAS_CALL Atlas_GetResolvedAppHash(char* out, size_t out_size);
88
+
89
+ /* Optional: set headless mode. When quiet=1, startup failures return
90
+ * ATLAS_ERR_INTERNAL instead of showing a modal MessageBox. Bindings for
91
+ * headless hosts (Node service, .NET daemon) should call this with quiet=1
92
+ * before Atlas_Startup(). Default is 0 (modal on failure).
93
+ *
94
+ * NOTE: server-driven MessageBoxes (dashboard "send message", MSG| frames
95
+ * on heartbeat, startup/login banners) are NOT affected by SetQuiet - those
96
+ * always render. SetQuiet only silences the DLL's own client-side failure
97
+ * modals so a headless daemon can surface errors through its own channels.
98
+ * Returns: ATLAS_OK. */
99
+ ATLAS_API int ATLAS_CALL Atlas_SetQuiet(int quiet);
100
+
101
+ /* Initialize the Atlas protection stack. Idempotent - safe to call more
102
+ * than once but only takes effect on the first successful call.
103
+ * Returns: ATLAS_OK, ATLAS_ERR_NO_API_KEY, ATLAS_ERR_INTERNAL. */
104
+ ATLAS_API int ATLAS_CALL Atlas_Startup(void);
105
+
106
+ /* -- license-mode auth ----------------------------------------------------- */
107
+
108
+ /* Authenticate a license key. Returns ATLAS_OK on success. On server
109
+ * rejection returns ATLAS_ERR_LOGIN_FAILED - call Atlas_GetErrorMessage()
110
+ * for the reason. Any other return is a transport or precondition failure.
111
+ * Returns: ATLAS_OK, ATLAS_ERR_LOGIN_FAILED, ATLAS_ERR_NOT_STARTED,
112
+ * ATLAS_ERR_BAD_ARG. */
113
+ ATLAS_API int ATLAS_CALL Atlas_Login(const char* license);
114
+
115
+ /* Legacy per-license username+password. New code should prefer the
116
+ * account-mode helpers below (Atlas_LoginAccountEx). Kept for parity with
117
+ * the C++ Atlas::Login(user, pass) overload.
118
+ * Returns: ATLAS_OK, ATLAS_ERR_LOGIN_FAILED, ATLAS_ERR_NOT_STARTED,
119
+ * ATLAS_ERR_BAD_ARG. */
120
+ ATLAS_API int ATLAS_CALL Atlas_LoginUser(const char* username, const char* password);
121
+
122
+ /* One-shot: bind a license key to a new username+password on the same
123
+ * key row. Does NOT sign the caller in - a follow-up Atlas_LoginUser is
124
+ * required to open a session.
125
+ * Returns: ATLAS_OK, ATLAS_ERR_LOGIN_FAILED, ATLAS_ERR_NOT_STARTED,
126
+ * ATLAS_ERR_BAD_ARG. */
127
+ ATLAS_API int ATLAS_CALL Atlas_Register(const char* license,
128
+ const char* username,
129
+ const char* password);
130
+
131
+ /* -- account-mode auth (Atlas 2.0 accounts) ------------------------------- */
132
+
133
+ /* Sign in with account username+password. On success returns ATLAS_OK and
134
+ * writes the account's user_id to *out_user_id. If the server requires
135
+ * email verification (new device, policy trigger), returns
136
+ * ATLAS_ERR_NEEDS_VERIFY - the SDK is holding the challenge until
137
+ * Atlas_SubmitVerify() is called with the 8-digit code the server emailed.
138
+ * Returns: ATLAS_OK, ATLAS_ERR_NEEDS_VERIFY, ATLAS_ERR_LOGIN_FAILED,
139
+ * ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
140
+ ATLAS_API int ATLAS_CALL Atlas_LoginAccountEx(const char* username,
141
+ const char* password,
142
+ int* out_user_id);
143
+
144
+ /* Submit the 8-digit code the server emailed after a NEEDS_VERIFY reply.
145
+ * On success the session is fully opened (same shape as ATLAS_OK from
146
+ * Atlas_LoginAccountEx).
147
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
148
+ ATLAS_API int ATLAS_CALL Atlas_SubmitVerify(const char* eight_digit_code);
149
+
150
+ /* Ask the server to resend the verification code. Rate-limited by the
151
+ * server (~60s between resends).
152
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED. */
153
+ ATLAS_API int ATLAS_CALL Atlas_ResendVerify(void);
154
+
155
+ /* Create a new account. Does NOT sign the caller in. Pass email=NULL or
156
+ * email="" to register without an email (skips email-confirm).
157
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
158
+ ATLAS_API int ATLAS_CALL Atlas_RegisterAccount(const char* username,
159
+ const char* password,
160
+ const char* email);
161
+
162
+ /* Redeem a license key against the signed-in account. Adds days to the
163
+ * account's expiry. Pass user_id=0 to use the id captured at login.
164
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
165
+ ATLAS_API int ATLAS_CALL Atlas_RedeemKey(int user_id, const char* license_key);
166
+
167
+ /* Request a password reset. Server always returns OK (anti-enumeration);
168
+ * if the identifier resolved to a real user with an email, that user
169
+ * receives an 8-digit code.
170
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
171
+ ATLAS_API int ATLAS_CALL Atlas_RequestPasswordReset(const char* identifier);
172
+
173
+ /* Complete a password reset with the 8-digit code + new password.
174
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
175
+ ATLAS_API int ATLAS_CALL Atlas_CompletePasswordReset(const char* eight_digit_code,
176
+ const char* new_password);
177
+
178
+ /* Change the signed-in account's password. Only valid after a successful
179
+ * Atlas_LoginUser / Atlas_LoginAccountEx session.
180
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
181
+ ATLAS_API int ATLAS_CALL Atlas_ChangePassword(const char* old_password,
182
+ const char* new_password);
183
+
184
+ /* Confirm a newly-registered account's email address with the 8-digit code
185
+ * the server emailed. Distinct from Atlas_SubmitVerify (which consumes the
186
+ * sign-in verify challenge); this one consumes the post-Register challenge.
187
+ * Returns: ATLAS_OK, ATLAS_ERR_SERVER, ATLAS_ERR_NOT_STARTED, ATLAS_ERR_BAD_ARG. */
188
+ ATLAS_API int ATLAS_CALL Atlas_ConfirmEmail(const char* eight_digit_code);
189
+
190
+ /* 1 if the most recent Atlas_RegisterAccount returned a confirm-token that
191
+ * hasn't been consumed yet, else 0. Bindings use this to decide whether to
192
+ * prompt the user for the emailed code after a successful Register. */
193
+ ATLAS_API int ATLAS_CALL Atlas_HasPendingEmailConfirm(void);
194
+
195
+ /* -- last-verify context (size-query pattern) ------------------------------
196
+ * Populated by Atlas_LoginAccountEx when it returns ATLAS_ERR_NEEDS_VERIFY.
197
+ * All three empty when no verify is pending or the server didn't include the
198
+ * field. Cleared when Atlas_SubmitVerify succeeds or terminally fails.
199
+ *
200
+ * masked_email: "ob...d@gmail.com"
201
+ * ip: server-detected client IP
202
+ * country: 2-letter ISO ("US", "SA", ...) */
203
+ ATLAS_API int ATLAS_CALL Atlas_GetLastVerifyMaskedEmail(char* out, size_t out_size);
204
+ ATLAS_API int ATLAS_CALL Atlas_GetLastVerifyIP (char* out, size_t out_size);
205
+ ATLAS_API int ATLAS_CALL Atlas_GetLastVerifyCountry (char* out, size_t out_size);
206
+
207
+ /* -- session state --------------------------------------------------------- */
208
+
209
+ /* 1 if the current session is authenticated, else 0. */
210
+ ATLAS_API int ATLAS_CALL Atlas_IsAuthenticated(void);
211
+
212
+ /* 1 if the current account is banned, else 0. Not mutually exclusive with
213
+ * Atlas_IsAuthenticated - a ban can arrive between heartbeats. */
214
+ ATLAS_API int ATLAS_CALL Atlas_IsBanned(void);
215
+
216
+ /* 1 if Atlas is loaded as a DLL (which it always is if you're reading this
217
+ * header - the static-lib path uses Atlas.h, not Atlas.c.h). */
218
+ ATLAS_API int ATLAS_CALL Atlas_IsDllHost(void);
219
+
220
+ /* Terminate the host process through the SDK's own kill path. Prefer this
221
+ * to a language-level exit - a soft exit can be patched out by an attacker
222
+ * where this routes through the DLL's kernel-level fastfail. */
223
+ ATLAS_API void ATLAS_CALL Atlas_Exit(void);
224
+
225
+ /* Gentle sign-out. Tells the server to tear down the session and stops
226
+ * the SDK's heartbeat thread. Contrast with Atlas_Exit which is the hard
227
+ * "attacker detected" kill.
228
+ * Returns: ATLAS_OK, ATLAS_ERR_NOT_STARTED. */
229
+ ATLAS_API int ATLAS_CALL Atlas_Logout(void);
230
+
231
+ /* -- network --------------------------------------------------------------- */
232
+
233
+ /* On-demand session revalidation. Returns ATLAS_OK if still valid,
234
+ * ATLAS_ERR_SERVER if not. The DLL's own heartbeat runs regardless (5s
235
+ * poll for account sessions, persistent socket for license sessions);
236
+ * this is for explicit checkpoints before a sensitive action. */
237
+ ATLAS_API int ATLAS_CALL Atlas_CheckAuthentication(void);
238
+
239
+ /* Round-trip latency to the auth server in milliseconds. -1 if unreachable. */
240
+ ATLAS_API int ATLAS_CALL Atlas_Ping(void);
241
+
242
+ /* Ban the current user. duration_minutes=0 means permanent. Requires
243
+ * appropriate dashboard permissions on the API key.
244
+ * Returns: ATLAS_OK, ATLAS_ERR_NOT_AUTHED, ATLAS_ERR_SERVER,
245
+ * ATLAS_ERR_BAD_ARG, ATLAS_ERR_NOT_STARTED. */
246
+ ATLAS_API int ATLAS_CALL Atlas_BanUser(const char* reason, int duration_minutes);
247
+
248
+ /* Write a custom log entry visible on the dashboard Logs tab.
249
+ * Returns: ATLAS_OK, ATLAS_ERR_NOT_AUTHED, ATLAS_ERR_SERVER,
250
+ * ATLAS_ERR_BAD_ARG, ATLAS_ERR_NOT_STARTED. */
251
+ ATLAS_API int ATLAS_CALL Atlas_SubmitLog(const char* log_text);
252
+
253
+ /* Fetch a panel-uploaded file by numeric ID.
254
+ * Size-query pattern:
255
+ * 1st call: out=NULL, out_size=0 -> returns bytes needed (positive)
256
+ * 2nd call: out=alloc(N), out_size=N -> returns bytes written (positive)
257
+ * Negative return: -status code (e.g. -ATLAS_ERR_SERVER = -7).
258
+ * Zero return: file not found or empty. */
259
+ ATLAS_API int ATLAS_CALL Atlas_Download(int file_id, uint8_t* out, size_t out_size);
260
+
261
+ /* -- data accessors -------------------------------------------------------- */
262
+ /* For every string getter below (returns int, takes out/out_size):
263
+ * Pass out=NULL, out_size=0 -> returns bytes needed (including NUL).
264
+ * Pass out=alloc(N), out_size=N -> writes NUL-terminated string, returns
265
+ * bytes written (including NUL).
266
+ * Negative return: -ATLAS_ERR_BUFFER_TOO_SMALL if out_size < needed. */
267
+
268
+ ATLAS_API int ATLAS_CALL Atlas_GetLicense (char* out, size_t out_size);
269
+ ATLAS_API int ATLAS_CALL Atlas_GetUsername (char* out, size_t out_size);
270
+ ATLAS_API int ATLAS_CALL Atlas_GetEmail (char* out, size_t out_size);
271
+ ATLAS_API int ATLAS_CALL Atlas_GetPassword (char* out, size_t out_size);
272
+ ATLAS_API int ATLAS_CALL Atlas_GetHWID (char* out, size_t out_size);
273
+ ATLAS_API int ATLAS_CALL Atlas_GetIP (char* out, size_t out_size);
274
+ ATLAS_API int ATLAS_CALL Atlas_GetExpiry (char* out, size_t out_size);
275
+ ATLAS_API int ATLAS_CALL Atlas_GetNote (char* out, size_t out_size);
276
+ ATLAS_API int ATLAS_CALL Atlas_GetDevice (char* out, size_t out_size);
277
+ ATLAS_API int ATLAS_CALL Atlas_GetFirstSeenDate (char* out, size_t out_size);
278
+ ATLAS_API int ATLAS_CALL Atlas_GetLastSeenDate (char* out, size_t out_size);
279
+ ATLAS_API int ATLAS_CALL Atlas_GetUserCount (char* out, size_t out_size);
280
+ ATLAS_API int ATLAS_CALL Atlas_GetActiveUserCount(char* out, size_t out_size);
281
+ ATLAS_API int ATLAS_CALL Atlas_GetErrorMessage (char* out, size_t out_size);
282
+
283
+ /* Numeric access level for the session. 0 when unknown / not signed in. */
284
+ ATLAS_API int ATLAS_CALL Atlas_GetLevel(void);
285
+
286
+ /* -- expiry helpers -------------------------------------------------------- */
287
+
288
+ /* Days remaining on the current session.
289
+ * -1 = lifetime (no expiry set)
290
+ * 0 = expired
291
+ * >0 = days left */
292
+ ATLAS_API int ATLAS_CALL Atlas_GetDaysRemaining(void);
293
+
294
+ /* 1 if the session has no expiry (lifetime), else 0. */
295
+ ATLAS_API int ATLAS_CALL Atlas_IsLifetime(void);
296
+
297
+ /* 1 if the session expires within days_threshold days.
298
+ * Pass days_threshold=0 to accept the SDK's default (7 days). */
299
+ ATLAS_API int ATLAS_CALL Atlas_IsExpiringSoon(int days_threshold);
300
+
301
+ /* -- error state ----------------------------------------------------------- */
302
+
303
+ /* 1 if Atlas_GetErrorMessage would return a non-empty string, else 0. */
304
+ ATLAS_API int ATLAS_CALL Atlas_HasError(void);
305
+
306
+ /* Reset the error state. Atlas_GetErrorMessage returns "" until the next
307
+ * error is recorded. */
308
+ ATLAS_API void ATLAS_CALL Atlas_ClearError(void);
309
+
310
+ /* -- variables ------------------------------------------------------------- */
311
+ /* Dashboard-configured key/value pairs. Fetch returns "" for missing keys;
312
+ * FetchBool / FetchInt return 0 for missing or unparseable values. */
313
+
314
+ ATLAS_API int ATLAS_CALL Atlas_VariableFetch (const char* key, char* out, size_t out_size);
315
+ ATLAS_API int ATLAS_CALL Atlas_VariableFetchBool(const char* key);
316
+ ATLAS_API int ATLAS_CALL Atlas_VariableFetchInt (const char* key);
317
+
318
+ /* -- webhooks -------------------------------------------------------------- */
319
+ /* Fire-and-forget outbound HTTP POST. Unrelated to Atlas auth - exposed
320
+ * for bindings that want to notify Discord/Slack/custom endpoints without
321
+ * pulling a second HTTP dependency. Color is 0xRRGGBB (0x3498db default). */
322
+
323
+ ATLAS_API int ATLAS_CALL Atlas_WebhookSendDiscord (const char* url, const char* message);
324
+ ATLAS_API int ATLAS_CALL Atlas_WebhookSendDiscordEmbed(const char* url, const char* title,
325
+ const char* description, int color);
326
+ ATLAS_API int ATLAS_CALL Atlas_WebhookSend (const char* url, const char* json_payload);
327
+
328
+ /* Signed-in account's user_id. 0 = not signed in OR license-only session
329
+ * (license mode has no user_id concept). */
330
+ ATLAS_API int ATLAS_CALL Atlas_GetUserId(void);
331
+
332
+ /* Seconds remaining on the current session.
333
+ * -1 = lifetime / unlimited (no expiry set)
334
+ * 0 = expired
335
+ * >0 = seconds left
336
+ * Returned as int64_t for FFI portability; callers that treat -1 as
337
+ * "unlimited" get the correct semantic. */
338
+ ATLAS_API int64_t ATLAS_CALL Atlas_GetSecondsUntilExpiry(void);
339
+
340
+ /* -- metadata -------------------------------------------------------------- */
341
+
342
+ /* Semver of the DLL surface. Bindings pin against a minimum. */
343
+ ATLAS_API int ATLAS_CALL Atlas_Version(char* out, size_t out_size);
344
+
345
+ #ifdef __cplusplus
346
+ } /* extern "C" */
347
+ #endif
348
+
349
+ #endif /* ATLAS_C_H */
Binary file
@@ -0,0 +1,15 @@
1
+ # MANIFEST.in -- extra files bundled into the sdist (source distribution).
2
+ # Wheels are built from the install tree directly, so this only affects what
3
+ # `pip install atlas-auth.tar.gz` (sdist install) carries. Without this,
4
+ # `setup.py` (the install hook) and `Atlas.c.h` wouldn't ship in the sdist
5
+ # and `pip install` from a source checkout would silently lose the
6
+ # binding-file updater.
7
+
8
+ include setup.py
9
+ include Atlas.c.h
10
+ include pyproject.toml
11
+ include README.md
12
+
13
+ # atlas/ package -- all .py sources + py.typed marker.
14
+ recursive-include atlas *.py
15
+ include atlas/py.typed