u2auth 0.2.1__tar.gz → 0.3.0__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.
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: u2auth
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: U2Auth SDK for Python — TOTP verification, push approvals, and local TOTP helpers
5
5
  Author-email: DollarMates Dev <dev@dollarmates.com>
6
6
  License-Expression: MIT
7
- Project-URL: Homepage, https://auth.u2secured.com/developer/docs
7
+ Project-URL: Homepage, https://u2secured.com/authenticator
8
+ Project-URL: Documentation, https://auth.u2secured.com/developer/docs
8
9
  Project-URL: Source, https://github.com/u2secured/u2auth
9
10
  Project-URL: Issues, https://github.com/u2secured/u2auth/issues
10
11
  Keywords: 2fa,mfa,totp,push,authentication,u2secured
@@ -24,6 +25,8 @@ Dynamic: license-file
24
25
 
25
26
  Python SDK for the U2Auth platform — TOTP verification, push approvals, and local TOTP helpers.
26
27
 
28
+ Part of [U2 Secured Authenticator](https://u2secured.com/authenticator) · [Documentation](https://auth.u2secured.com/developer/docs)
29
+
27
30
  ## Install
28
31
 
29
32
  ```bash
@@ -212,6 +215,28 @@ while True:
212
215
  cursor = page["next_cursor"]
213
216
  ```
214
217
 
218
+ ### `client.list_sign_in_log(*, limit=0, cursor="") -> dict`
219
+
220
+ Calls `GET /api/v1/sdk/sign-in-log`. Returns `{"items": [...], "next_cursor": "...", "has_more": bool}`, oldest first. `limit` defaults to 500 on the server (max 1000); `limit <= 0` is omitted, as is an empty `cursor`. Raises `U2AuthError` with code `INVALID_CURSOR` for a malformed cursor, or `MACHINE_KEY_NOT_ALLOWED` if called with a machine key — use an app key.
221
+
222
+ #### Export the sign-in log
223
+
224
+ Pull the log on a schedule: load your saved cursor, call `list_sign_in_log`, persist `next_cursor`, and repeat while `has_more` is true.
225
+
226
+ ```python
227
+ cursor = load_cursor() # "" on the first run
228
+ while True:
229
+ page = client.list_sign_in_log(limit=1000, cursor=cursor)
230
+ for ev in page["items"]:
231
+ store(ev)
232
+ cursor = page["next_cursor"]
233
+ save_cursor(cursor)
234
+ if not page["has_more"]:
235
+ break
236
+ ```
237
+
238
+ Notes: rows are served about 30 seconds after they are recorded, so a fresh sign-in may not appear immediately. An expired push and its machine report both appear as separate rows; they are related by `approval_id`.
239
+
215
240
  ### Helpers (no API call)
216
241
 
217
242
  ```python
@@ -1,29 +1,9 @@
1
- Metadata-Version: 2.4
2
- Name: u2auth
3
- Version: 0.2.1
4
- Summary: U2Auth SDK for Python — TOTP verification, push approvals, and local TOTP helpers
5
- Author-email: DollarMates Dev <dev@dollarmates.com>
6
- License-Expression: MIT
7
- Project-URL: Homepage, https://auth.u2secured.com/developer/docs
8
- Project-URL: Source, https://github.com/u2secured/u2auth
9
- Project-URL: Issues, https://github.com/u2secured/u2auth/issues
10
- Keywords: 2fa,mfa,totp,push,authentication,u2secured
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Topic :: Security
14
- Requires-Python: >=3.9
15
- Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Provides-Extra: dev
18
- Requires-Dist: pytest>=7.0; extra == "dev"
19
- Requires-Dist: build>=1.0; extra == "dev"
20
- Requires-Dist: twine>=5.0; extra == "dev"
21
- Dynamic: license-file
22
-
23
1
  # u2auth
24
2
 
25
3
  Python SDK for the U2Auth platform — TOTP verification, push approvals, and local TOTP helpers.
26
4
 
5
+ Part of [U2 Secured Authenticator](https://u2secured.com/authenticator) · [Documentation](https://auth.u2secured.com/developer/docs)
6
+
27
7
  ## Install
28
8
 
29
9
  ```bash
@@ -212,6 +192,28 @@ while True:
212
192
  cursor = page["next_cursor"]
213
193
  ```
214
194
 
195
+ ### `client.list_sign_in_log(*, limit=0, cursor="") -> dict`
196
+
197
+ Calls `GET /api/v1/sdk/sign-in-log`. Returns `{"items": [...], "next_cursor": "...", "has_more": bool}`, oldest first. `limit` defaults to 500 on the server (max 1000); `limit <= 0` is omitted, as is an empty `cursor`. Raises `U2AuthError` with code `INVALID_CURSOR` for a malformed cursor, or `MACHINE_KEY_NOT_ALLOWED` if called with a machine key — use an app key.
198
+
199
+ #### Export the sign-in log
200
+
201
+ Pull the log on a schedule: load your saved cursor, call `list_sign_in_log`, persist `next_cursor`, and repeat while `has_more` is true.
202
+
203
+ ```python
204
+ cursor = load_cursor() # "" on the first run
205
+ while True:
206
+ page = client.list_sign_in_log(limit=1000, cursor=cursor)
207
+ for ev in page["items"]:
208
+ store(ev)
209
+ cursor = page["next_cursor"]
210
+ save_cursor(cursor)
211
+ if not page["has_more"]:
212
+ break
213
+ ```
214
+
215
+ Notes: rows are served about 30 seconds after they are recorded, so a fresh sign-in may not appear immediately. An expired push and its machine report both appear as separate rows; they are related by `approval_id`.
216
+
215
217
  ### Helpers (no API call)
216
218
 
217
219
  ```python
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "u2auth"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "U2Auth SDK for Python — TOTP verification, push approvals, and local TOTP helpers"
9
9
  authors = [{ name = "DollarMates Dev", email = "dev@dollarmates.com" }]
10
10
  requires-python = ">=3.9"
@@ -19,7 +19,8 @@ classifiers = [
19
19
  ]
20
20
 
21
21
  [project.urls]
22
- Homepage = "https://auth.u2secured.com/developer/docs"
22
+ Homepage = "https://u2secured.com/authenticator"
23
+ Documentation = "https://auth.u2secured.com/developer/docs"
23
24
  Source = "https://github.com/u2secured/u2auth"
24
25
  Issues = "https://github.com/u2secured/u2auth/issues"
25
26
 
@@ -605,6 +605,104 @@ class TestListEnrolmentEvents:
605
605
  srv.stop()
606
606
 
607
607
 
608
+ class TestListSignInLog:
609
+ PATH = "/api/v1/sdk/sign-in-log"
610
+
611
+ def _srv(self, body=None, status=200, **kw):
612
+ return MockServer(
613
+ make_handler(
614
+ status,
615
+ body if body is not None else {"items": [], "next_cursor": "", "has_more": False},
616
+ assert_method="GET",
617
+ assert_path=self.PATH,
618
+ **kw,
619
+ )
620
+ )
621
+
622
+ def test_default_call_sends_auth_and_no_query(self):
623
+ srv = self._srv(assert_query={}, assert_auth="Bearer rka_test")
624
+ Client("rka_test", base_url=srv.url).list_sign_in_log()
625
+ srv.stop()
626
+
627
+ def test_limit_and_cursor_included_when_given(self):
628
+ srv = self._srv(assert_query={"limit": "1000", "cursor": "abc"})
629
+ Client("rka_test", base_url=srv.url).list_sign_in_log(limit=1000, cursor="abc")
630
+ srv.stop()
631
+
632
+ def test_zero_limit_is_omitted(self):
633
+ srv = self._srv(assert_query={})
634
+ Client("rka_test", base_url=srv.url).list_sign_in_log(limit=0)
635
+ srv.stop()
636
+
637
+ def test_negative_limit_is_omitted(self):
638
+ srv = self._srv(assert_query={})
639
+ Client("rka_test", base_url=srv.url).list_sign_in_log(limit=-1)
640
+ srv.stop()
641
+
642
+ def test_empty_cursor_is_omitted(self):
643
+ srv = self._srv(assert_query={"limit": "5"})
644
+ Client("rka_test", base_url=srv.url).list_sign_in_log(limit=5, cursor="")
645
+ srv.stop()
646
+
647
+ def test_cursor_is_url_encoded(self):
648
+ raw = "a+b/c=d e&f"
649
+ srv = self._srv(assert_query={"cursor": raw})
650
+ Client("rka_test", base_url=srv.url).list_sign_in_log(cursor=raw)
651
+ srv.stop()
652
+
653
+ def test_decodes_fleet_and_push_rows_preserving_nulls(self):
654
+ fleet = {
655
+ "id": "e1", "occurred_at": "2026-11-10T00:00:00Z",
656
+ "received_at": "2026-11-10T00:00:05Z", "user_identifier": "alice",
657
+ "local_login": "alice", "kind": "machine", "origin": "ssh",
658
+ "method": "push", "outcome": "approved", "reason": "ok",
659
+ "city": "Berlin", "region": "", "country": "DE", "new_country": True,
660
+ "source_ip": "203.0.113.9", "machine_id": "m1", "machine_name": "web-1",
661
+ "service": "sshd", "context": "login", "approval_id": "ap1",
662
+ "seq": 7, "gap_count": 0, "clock_skew_seconds": 2,
663
+ }
664
+ push = {
665
+ "id": "e2", "occurred_at": "2026-11-10T00:01:00Z",
666
+ "received_at": "2026-11-10T00:01:01Z", "user_identifier": "bob",
667
+ "local_login": None, "kind": "push", "origin": "app",
668
+ "method": "push", "outcome": "approved", "reason": None,
669
+ "city": None, "region": None, "country": None, "new_country": False,
670
+ "source_ip": None, "machine_id": None, "machine_name": None,
671
+ "service": None, "context": None, "approval_id": "ap2",
672
+ "seq": None, "gap_count": None, "clock_skew_seconds": None,
673
+ }
674
+ srv = self._srv({"items": [fleet, push], "next_cursor": "c2", "has_more": True})
675
+ result = Client("rka_test", base_url=srv.url).list_sign_in_log()
676
+ srv.stop()
677
+ assert result == {"items": [fleet, push], "next_cursor": "c2", "has_more": True}
678
+ assert result["items"][0]["machine_id"] == "m1"
679
+ assert result["items"][0]["region"] == ""
680
+ assert result["items"][1]["city"] is None
681
+ assert result["items"][1]["machine_id"] is None
682
+ assert result["has_more"] is True
683
+
684
+ def test_invalid_cursor_surfaces_code(self):
685
+ srv = self._srv(
686
+ {"error": {"code": "INVALID_CURSOR", "message": "bad cursor"}}, status=400
687
+ )
688
+ with pytest.raises(U2AuthError) as exc:
689
+ Client("rka_test", base_url=srv.url).list_sign_in_log(cursor="zzz")
690
+ srv.stop()
691
+ assert exc.value.code == "INVALID_CURSOR"
692
+ assert exc.value.status_code == 400
693
+
694
+ def test_machine_key_not_allowed_surfaces_code(self):
695
+ srv = self._srv(
696
+ {"error": {"code": "MACHINE_KEY_NOT_ALLOWED", "message": "use an app key"}},
697
+ status=403,
698
+ )
699
+ with pytest.raises(U2AuthError) as exc:
700
+ Client("rka_test", base_url=srv.url).list_sign_in_log()
701
+ srv.stop()
702
+ assert exc.value.code == "MACHINE_KEY_NOT_ALLOWED"
703
+ assert exc.value.status_code == 403
704
+
705
+
608
706
  class TestListEnrolmentsUserIdentifier:
609
707
  def test_user_identifier_included_when_given(self):
610
708
  srv = MockServer(
@@ -239,6 +239,30 @@ class Client:
239
239
  path = f"/api/v1/sdk/enrolments/{enrolment_path}/events"
240
240
  return self._get(f"{path}?{query}" if query else path)
241
241
 
242
+ def list_sign_in_log(self, *, limit: int = 0, cursor: str = "") -> Dict[str, Any]:
243
+ """Pull the app's sign-in log, oldest first.
244
+
245
+ limit <= 0 is treated as unset and omitted from the query (the server
246
+ default is 500, max 1000), same as an empty cursor.
247
+
248
+ cursor is opaque; pass back the previous page's next_cursor verbatim.
249
+ Rows are served about 30 seconds after they are recorded.
250
+
251
+ Raises U2AuthError with code 'INVALID_CURSOR' if cursor is malformed,
252
+ or 'MACHINE_KEY_NOT_ALLOWED' if called with a machine key (use an app
253
+ key).
254
+
255
+ Returns {'items': [...], 'next_cursor': '...', 'has_more': bool}.
256
+ """
257
+ params: Dict[str, Any] = {}
258
+ if limit > 0:
259
+ params["limit"] = limit
260
+ if cursor:
261
+ params["cursor"] = cursor
262
+ query = urllib.parse.urlencode(params)
263
+ path = "/api/v1/sdk/sign-in-log"
264
+ return self._get(f"{path}?{query}" if query else path)
265
+
242
266
  def _post(
243
267
  self, path: str, body: Dict[str, Any], headers: Optional[Dict[str, str]] = None
244
268
  ) -> Dict[str, Any]:
@@ -1,7 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: u2auth
3
+ Version: 0.3.0
4
+ Summary: U2Auth SDK for Python — TOTP verification, push approvals, and local TOTP helpers
5
+ Author-email: DollarMates Dev <dev@dollarmates.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://u2secured.com/authenticator
8
+ Project-URL: Documentation, https://auth.u2secured.com/developer/docs
9
+ Project-URL: Source, https://github.com/u2secured/u2auth
10
+ Project-URL: Issues, https://github.com/u2secured/u2auth/issues
11
+ Keywords: 2fa,mfa,totp,push,authentication,u2secured
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Security
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=7.0; extra == "dev"
20
+ Requires-Dist: build>=1.0; extra == "dev"
21
+ Requires-Dist: twine>=5.0; extra == "dev"
22
+ Dynamic: license-file
23
+
1
24
  # u2auth
2
25
 
3
26
  Python SDK for the U2Auth platform — TOTP verification, push approvals, and local TOTP helpers.
4
27
 
28
+ Part of [U2 Secured Authenticator](https://u2secured.com/authenticator) · [Documentation](https://auth.u2secured.com/developer/docs)
29
+
5
30
  ## Install
6
31
 
7
32
  ```bash
@@ -190,6 +215,28 @@ while True:
190
215
  cursor = page["next_cursor"]
191
216
  ```
192
217
 
218
+ ### `client.list_sign_in_log(*, limit=0, cursor="") -> dict`
219
+
220
+ Calls `GET /api/v1/sdk/sign-in-log`. Returns `{"items": [...], "next_cursor": "...", "has_more": bool}`, oldest first. `limit` defaults to 500 on the server (max 1000); `limit <= 0` is omitted, as is an empty `cursor`. Raises `U2AuthError` with code `INVALID_CURSOR` for a malformed cursor, or `MACHINE_KEY_NOT_ALLOWED` if called with a machine key — use an app key.
221
+
222
+ #### Export the sign-in log
223
+
224
+ Pull the log on a schedule: load your saved cursor, call `list_sign_in_log`, persist `next_cursor`, and repeat while `has_more` is true.
225
+
226
+ ```python
227
+ cursor = load_cursor() # "" on the first run
228
+ while True:
229
+ page = client.list_sign_in_log(limit=1000, cursor=cursor)
230
+ for ev in page["items"]:
231
+ store(ev)
232
+ cursor = page["next_cursor"]
233
+ save_cursor(cursor)
234
+ if not page["has_more"]:
235
+ break
236
+ ```
237
+
238
+ Notes: rows are served about 30 seconds after they are recorded, so a fresh sign-in may not appear immediately. An expired push and its machine report both appear as separate rows; they are related by `approval_id`.
239
+
193
240
  ### Helpers (no API call)
194
241
 
195
242
  ```python
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes