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