nf-ndc-connect-public 0.3.1__cp312-cp312-manylinux_2_34_x86_64.whl

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,5 @@
1
+ from .nf_ndc_connect_public import *
2
+
3
+ __doc__ = nf_ndc_connect_public.__doc__
4
+ if hasattr(nf_ndc_connect_public, "__all__"):
5
+ __all__ = nf_ndc_connect_public.__all__
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: nf_ndc_connect_public
3
+ Version: 0.3.1
4
+ Summary: Add your description here
5
+ Author-email: dhilipsiva <dhilipsiva@pm.me>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
8
+
9
+ # nf_ndc_connect_public
10
+
11
+ **One Logic, Three Platforms.**
12
+ This library provides a unified, secure, and high-performance Identity Provider (IDP) Claims & Authorization helper. It is written in **Rust** and compiled for:
13
+
14
+ * **Rust** (Native Crate)
15
+ * **Python** (via PyO3)
16
+ * **Node.js / Web** (via Wasm-Pack)
17
+
18
+ It handles JWT validation, Role-Based Access Control (RBAC) checks, and parsing of complex IDP organization trees.
19
+
20
+ ---
21
+
22
+ ## 📦 Installation
23
+
24
+ ### 🦀 Rust
25
+
26
+ ```bash
27
+ cargo add nf_ndc_connect_public
28
+
29
+ ```
30
+
31
+ ### 🐍 Python
32
+
33
+ ```bash
34
+ pip install nf_ndc_connect_public
35
+
36
+ ```
37
+
38
+ ### 📦 Node.js (npm)
39
+
40
+ ```bash
41
+ npm install @dhilipsiva/nf_ndc_connect_public
42
+
43
+ ```
44
+
45
+ ---
46
+
47
+ ## 🚀 Usage
48
+
49
+ ### 🐍 Python Example
50
+
51
+ ```python
52
+ import nf_ndc_connect_public
53
+ import json
54
+
55
+ # 1. Initialize with your Public Key (PEM format)
56
+ with open("cert.pem", "r") as f:
57
+ public_key = f.read()
58
+
59
+ helper = nf_ndc_connect_public.IdpAuthHelper(public_key)
60
+
61
+ # 2. Validate a JWT
62
+ raw_jwt = "eyJhbGciOiJ..."
63
+ if helper.is_valid(raw_jwt):
64
+ print("✅ JWT is valid!")
65
+
66
+ # 3. Check specific Roles or Permissions
67
+ org_id = "dhilipsiva_dev/nf-apex"
68
+ if helper.has_role(raw_jwt, org_id, "nf-apex-adm"):
69
+ print("User is an Admin!")
70
+
71
+ # 4. Get full authorization tree (returns JSON string)
72
+ tree_json = helper.get_org_authorisations(raw_jwt)
73
+ print(json.loads(tree_json))
74
+ else:
75
+ print("❌ Invalid or Expired Token")
76
+
77
+ ```
78
+
79
+ ### 📦 Node.js Example
80
+
81
+ ```javascript
82
+ const { IdpAuthHelper } = require("@dhilipsiva/nf_ndc_connect_public");
83
+ const fs = require("fs");
84
+
85
+ // 1. Initialize
86
+ const publicKey = fs.readFileSync("./cert.pem", "utf8");
87
+ const helper = new IdpAuthHelper(publicKey);
88
+
89
+ const rawJwt = "eyJhbGciOiJ...";
90
+
91
+ // 2. Validate
92
+ const isValid = helper.isValid(rawJwt);
93
+ console.log(`Is Valid? ${isValid}`);
94
+
95
+ if (isValid) {
96
+ // 3. Check Role
97
+ const hasRole = helper.hasRole(rawJwt, "dhilipsiva_dev/nf-apex", "nf-apex-adm");
98
+ console.log(`Has Admin Role? ${hasRole}`);
99
+
100
+ // 4. Get Auth Tree
101
+ // Returns a native JS object (not a string) in Node
102
+ const tree = helper.getOrgAuthorisations(rawJwt);
103
+ console.log(tree);
104
+ }
105
+
106
+ ```
107
+
108
+ ### 🦀 Rust Example
109
+
110
+ ```rust
111
+ use nf_ndc_connect_public::AuthHelper;
112
+
113
+ fn main() {
114
+ let public_key = include_str!("../cert.pem");
115
+ let helper = AuthHelper::new(public_key).expect("Invalid Key");
116
+
117
+ let jwt = "eyJhbGciOiJ...";
118
+
119
+ match helper.is_valid(jwt) {
120
+ Ok(claims) => {
121
+ println!("✅ Valid Token for subject: {}", claims.sub);
122
+
123
+ if helper.has_role(jwt, "dhilipsiva_dev/nf-apex", "nf-apex-adm") {
124
+ println!("User is Admin");
125
+ }
126
+ },
127
+ Err(e) => println!("❌ Error: {}", e),
128
+ }
129
+ }
130
+
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 🛠️ Development
136
+
137
+ This project uses **Nix** for a reproducible environment and **Just** for command automation.
138
+
139
+ ### Prerequisites
140
+
141
+ 1. Install [Nix](https://nixos.org/download.html).
142
+ 2. Enable flakes (standard in newer installers).
143
+
144
+ ### Setup
145
+
146
+ Enter the development shell. This installs Rust, Python, Maturin, Node.js, and Wasm-Pack automatically.
147
+
148
+ ```bash
149
+ nix develop
150
+
151
+ ```
152
+
153
+ ### Build Commands (via `just`)
154
+
155
+ | Command | Description |
156
+ | --- | --- |
157
+ | `just py-dev` | Build Python wheel in debug mode & install to venv |
158
+ | `just py-build` | Build Python wheel for release |
159
+ | `just wasm` | Build the Wasm package for Node.js |
160
+ | `just test` | Run standard Cargo tests |
161
+ | `just clean` | Remove all build artifacts (`target/`, `pkg/`, `.venv/`) |
162
+
163
+ ### 🚢 Release Process
164
+
165
+ To publish a new version to PyPI, NPM, and Crates.io simultaneously:
166
+
167
+ 1. **Ensure you are in the Nix shell** (`nix develop`).
168
+ 2. **Run the release command:**
169
+ ```bash
170
+ # Usage: just release <version>
171
+ just release 0.2.3
172
+
173
+ ```
174
+
175
+
176
+ This will:
177
+ * Update `Cargo.toml` and `pyproject.toml`.
178
+ * Run checks.
179
+ * Commit the changes.
180
+ * Create a git tag `v0.2.3`.
181
+
182
+
183
+ 3. **Push to trigger CI/CD:**
184
+ ```bash
185
+ git push && git push --tags
186
+
187
+ ```
188
+
@@ -0,0 +1,5 @@
1
+ nf_ndc_connect_public/__init__.py,sha256=TieycIJatcb2KGf0CqtFlbKwfq6VEyRFNK2QDoXm858,167
2
+ nf_ndc_connect_public/nf_ndc_connect_public.cpython-312-x86_64-linux-gnu.so,sha256=QK561HxSVwSXx0RuyJAc84BET3FkDl4t9pxHlNJqOk8,1286040
3
+ nf_ndc_connect_public-0.3.1.dist-info/METADATA,sha256=OuRf1Uk0yj4fs890aDxHZxzvuQ-dM7AxCc_6kYxRNE0,4152
4
+ nf_ndc_connect_public-0.3.1.dist-info/WHEEL,sha256=6XxsoRAefLjPtdxftyk9ZM9Li3h1rlKFcn0YmUowGJA,109
5
+ nf_ndc_connect_public-0.3.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.5)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-manylinux_2_34_x86_64