u2auth 0.1.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.
u2auth-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DollarMates Pty Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
u2auth-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: u2auth
3
+ Version: 0.1.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://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
+ # u2auth
24
+
25
+ Python SDK for the U2Auth platform — TOTP verification, push approvals, and local TOTP helpers.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install u2auth
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ```python
36
+ from u2auth import Client, generate_secret, generate_qr_code_uri
37
+
38
+ client = Client("rka_your_api_key")
39
+ result = client.verify_totp("BASE32SECRET", "123456")
40
+ push = client.request_push("user@example.com", "Login from Chrome")
41
+ status = client.get_push_status(push["approval_id"])
42
+ secret = generate_secret()
43
+ uri = generate_qr_code_uri("MyApp", "user@example.com", secret)
44
+ ```
45
+
46
+ ## API Reference
47
+
48
+ ### `Client(api_key, *, base_url?)`
49
+
50
+ Sync API client. `base_url` defaults to `https://app.u2secured.io`.
51
+
52
+ ### `client.verify_totp(secret, code) -> dict`
53
+
54
+ Calls `POST /api/v1/sdk/totp/verify`. Returns `{"valid": bool}`.
55
+
56
+ ### `client.request_push(user_identifier, context, *, webhook_url?, ttl?) -> dict`
57
+
58
+ Calls `POST /api/v1/sdk/push/request`. Returns `{approval_id, status, expires_at}`.
59
+
60
+ `user_identifier` matching is case-sensitive and otherwise unnormalised — it's your own key into
61
+ your system, not ours, so folding case could silently merge two genuinely different users. Pass
62
+ the exact same string here as the one given to `create_pairing_code`. A mismatch (most often a
63
+ casing difference) raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` — no enrolment at all for
64
+ that identifier — which is distinct from `NO_DEVICE` (enrolled, but no confirmed device yet).
65
+
66
+ ### `client.get_push_status(approval_id) -> dict`
67
+
68
+ Calls `GET /api/v1/sdk/push/{id}/status`. Returns `{approval_id, status}`.
69
+
70
+ ### `client.delete_enrolment(user_identifier) -> None`
71
+
72
+ Calls `DELETE /api/v1/sdk/enrolments`. Raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` if there was none.
73
+
74
+ ### `client.list_enrolments(*, limit=25, cursor="", sort="created_at", order="desc") -> dict`
75
+
76
+ Calls `GET /api/v1/sdk/enrolments`. The app is resolved from the API key — there is no `app_id` parameter. Returns `{"items": [...], "next_cursor": "..."}`.
77
+
78
+ `sort` is one of `"created_at"`, `"user_identifier"`, `"last_auth_at"`; `order` is `"asc"` or `"desc"`. `next_cursor` is opaque and bound to the `sort`/`order` that minted it — pass it back verbatim on the next call. Replaying it under a different `sort`/`order` raises `U2AuthError` with code `INVALID_CURSOR`. `limit <= 0` is treated as unset and omitted from the query, same as an empty `cursor`; a `limit` outside `1..100` raises code `INVALID_LIMIT`.
79
+
80
+ For an enrolment that has never authenticated, `last_auth_at` and `last_auth_outcome` are both `None` rather than a zero time / empty string.
81
+
82
+ ### `client.list_enrolment_events(enrolment_id, *, limit=25, cursor="") -> dict`
83
+
84
+ Calls `GET /api/v1/sdk/enrolments/{enrolment_id}/events`. Returns `{"items": [...], "next_cursor": "..."}`.
85
+
86
+ `limit <= 0` is treated as unset and omitted from the query, same as an empty `cursor`. Raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` if there is no such enrolment, `INVALID_LIMIT` if `limit` is outside `1..100`, or `INVALID_CURSOR` if `cursor` is malformed or was minted for a different enrolment. Each event's `place` is a coarse, city-level location (`{"city", "region", "country"}` — never a coordinate) or `None` when no fix was captured; `region` can legitimately be an empty string, which is distinct from a `None` place.
87
+
88
+ ```python
89
+ cursor = ""
90
+ while True:
91
+ page = client.list_enrolments(limit=50, cursor=cursor)
92
+ for enrolment in page["items"]:
93
+ print(enrolment["user_identifier"], enrolment["last_auth_at"])
94
+ if not page["next_cursor"]:
95
+ break
96
+ cursor = page["next_cursor"]
97
+ ```
98
+
99
+ ### Helpers (no API call)
100
+
101
+ ```python
102
+ generate_secret(byte_len=20) -> str
103
+ generate_qr_code_uri(issuer, account, secret, *, algorithm="SHA1", digits=6, period=30) -> str
104
+ generate_recovery_codes(count=10) -> list[str]
105
+ ```
106
+
107
+ ### Error Handling
108
+
109
+ API errors raise `U2AuthError` with `.status_code` and `.code` attributes.
110
+
111
+ ## Verifying webhooks
112
+
113
+ ```python
114
+ from u2auth import verify_webhook, U2AuthError
115
+
116
+ try:
117
+ event = verify_webhook(raw_body, request.headers["X-U2Auth-Signature"], webhook_secret)
118
+ except U2AuthError:
119
+ ... # reject: bad signature or stale timestamp
120
+ # event.approval_id, event.status, event.reason, event.resolved_at
121
+ ```
122
+
123
+ Pass the **raw request body** (bytes/str), not a re-serialized dict. Handlers should dedupe on `event.approval_id`.
124
+
125
+ The push-request response includes `match_number` (the 2-digit number to show on your login page); `get_push_status` returns `status` plus `reason`/`resolved_at` once resolved.
u2auth-0.1.0/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # u2auth
2
+
3
+ Python SDK for the U2Auth platform — TOTP verification, push approvals, and local TOTP helpers.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install u2auth
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from u2auth import Client, generate_secret, generate_qr_code_uri
15
+
16
+ client = Client("rka_your_api_key")
17
+ result = client.verify_totp("BASE32SECRET", "123456")
18
+ push = client.request_push("user@example.com", "Login from Chrome")
19
+ status = client.get_push_status(push["approval_id"])
20
+ secret = generate_secret()
21
+ uri = generate_qr_code_uri("MyApp", "user@example.com", secret)
22
+ ```
23
+
24
+ ## API Reference
25
+
26
+ ### `Client(api_key, *, base_url?)`
27
+
28
+ Sync API client. `base_url` defaults to `https://app.u2secured.io`.
29
+
30
+ ### `client.verify_totp(secret, code) -> dict`
31
+
32
+ Calls `POST /api/v1/sdk/totp/verify`. Returns `{"valid": bool}`.
33
+
34
+ ### `client.request_push(user_identifier, context, *, webhook_url?, ttl?) -> dict`
35
+
36
+ Calls `POST /api/v1/sdk/push/request`. Returns `{approval_id, status, expires_at}`.
37
+
38
+ `user_identifier` matching is case-sensitive and otherwise unnormalised — it's your own key into
39
+ your system, not ours, so folding case could silently merge two genuinely different users. Pass
40
+ the exact same string here as the one given to `create_pairing_code`. A mismatch (most often a
41
+ casing difference) raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` — no enrolment at all for
42
+ that identifier — which is distinct from `NO_DEVICE` (enrolled, but no confirmed device yet).
43
+
44
+ ### `client.get_push_status(approval_id) -> dict`
45
+
46
+ Calls `GET /api/v1/sdk/push/{id}/status`. Returns `{approval_id, status}`.
47
+
48
+ ### `client.delete_enrolment(user_identifier) -> None`
49
+
50
+ Calls `DELETE /api/v1/sdk/enrolments`. Raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` if there was none.
51
+
52
+ ### `client.list_enrolments(*, limit=25, cursor="", sort="created_at", order="desc") -> dict`
53
+
54
+ Calls `GET /api/v1/sdk/enrolments`. The app is resolved from the API key — there is no `app_id` parameter. Returns `{"items": [...], "next_cursor": "..."}`.
55
+
56
+ `sort` is one of `"created_at"`, `"user_identifier"`, `"last_auth_at"`; `order` is `"asc"` or `"desc"`. `next_cursor` is opaque and bound to the `sort`/`order` that minted it — pass it back verbatim on the next call. Replaying it under a different `sort`/`order` raises `U2AuthError` with code `INVALID_CURSOR`. `limit <= 0` is treated as unset and omitted from the query, same as an empty `cursor`; a `limit` outside `1..100` raises code `INVALID_LIMIT`.
57
+
58
+ For an enrolment that has never authenticated, `last_auth_at` and `last_auth_outcome` are both `None` rather than a zero time / empty string.
59
+
60
+ ### `client.list_enrolment_events(enrolment_id, *, limit=25, cursor="") -> dict`
61
+
62
+ Calls `GET /api/v1/sdk/enrolments/{enrolment_id}/events`. Returns `{"items": [...], "next_cursor": "..."}`.
63
+
64
+ `limit <= 0` is treated as unset and omitted from the query, same as an empty `cursor`. Raises `U2AuthError` with code `ENROLMENT_NOT_FOUND` if there is no such enrolment, `INVALID_LIMIT` if `limit` is outside `1..100`, or `INVALID_CURSOR` if `cursor` is malformed or was minted for a different enrolment. Each event's `place` is a coarse, city-level location (`{"city", "region", "country"}` — never a coordinate) or `None` when no fix was captured; `region` can legitimately be an empty string, which is distinct from a `None` place.
65
+
66
+ ```python
67
+ cursor = ""
68
+ while True:
69
+ page = client.list_enrolments(limit=50, cursor=cursor)
70
+ for enrolment in page["items"]:
71
+ print(enrolment["user_identifier"], enrolment["last_auth_at"])
72
+ if not page["next_cursor"]:
73
+ break
74
+ cursor = page["next_cursor"]
75
+ ```
76
+
77
+ ### Helpers (no API call)
78
+
79
+ ```python
80
+ generate_secret(byte_len=20) -> str
81
+ generate_qr_code_uri(issuer, account, secret, *, algorithm="SHA1", digits=6, period=30) -> str
82
+ generate_recovery_codes(count=10) -> list[str]
83
+ ```
84
+
85
+ ### Error Handling
86
+
87
+ API errors raise `U2AuthError` with `.status_code` and `.code` attributes.
88
+
89
+ ## Verifying webhooks
90
+
91
+ ```python
92
+ from u2auth import verify_webhook, U2AuthError
93
+
94
+ try:
95
+ event = verify_webhook(raw_body, request.headers["X-U2Auth-Signature"], webhook_secret)
96
+ except U2AuthError:
97
+ ... # reject: bad signature or stale timestamp
98
+ # event.approval_id, event.status, event.reason, event.resolved_at
99
+ ```
100
+
101
+ Pass the **raw request body** (bytes/str), not a re-serialized dict. Handlers should dedupe on `event.approval_id`.
102
+
103
+ The push-request response includes `match_number` (the 2-digit number to show on your login page); `get_push_status` returns `status` plus `reason`/`resolved_at` once resolved.
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "u2auth"
7
+ version = "0.1.0"
8
+ description = "U2Auth SDK for Python — TOTP verification, push approvals, and local TOTP helpers"
9
+ authors = [{ name = "DollarMates Dev", email = "dev@dollarmates.com" }]
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ readme = "README.md"
14
+ keywords = ["2fa", "mfa", "totp", "push", "authentication", "u2secured"]
15
+ classifiers = [
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Topic :: Security",
19
+ ]
20
+
21
+ [project.urls]
22
+ Homepage = "https://auth.u2secured.com/developer/docs"
23
+ Source = "https://github.com/u2secured/u2auth"
24
+ Issues = "https://github.com/u2secured/u2auth/issues"
25
+
26
+ [project.optional-dependencies]
27
+ dev = ["pytest>=7.0", "build>=1.0", "twine>=5.0"]
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["."]
31
+ include = ["u2auth*"]
32
+
33
+ [tool.setuptools.package-data]
34
+ u2auth = ["py.typed"]
u2auth-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+