Add your description here
Project description
nf_ndc_connect_public
One Logic, Three Platforms. This library provides a unified, secure, and high-performance Identity Provider (IDP) Claims & Authorization helper. It is written in Rust and compiled for:
- Rust (Native Crate)
- Python (via PyO3)
- Node.js / Web (via Wasm-Pack)
It handles JWT validation, Role-Based Access Control (RBAC) checks, and parsing of complex IDP organization trees.
📦 Installation
🦀 Rust
cargo add nf_ndc_connect_public
🐍 Python
pip install nf_ndc_connect_public
📦 Node.js (npm)
npm install @dhilipsiva/nf_ndc_connect_public
🚀 Usage
🐍 Python Example
import nf_ndc_connect_public
import json
# 1. Initialize with your Public Key (PEM format)
with open("cert.pem", "r") as f:
public_key = f.read()
helper = nf_ndc_connect_public.IdpAuthHelper(public_key)
# 2. Validate a JWT
raw_jwt = "eyJhbGciOiJ..."
if helper.is_valid(raw_jwt):
print("✅ JWT is valid!")
# 3. Check specific Roles or Permissions
org_id = "dhilipsiva_dev/nf-apex"
if helper.has_role(raw_jwt, org_id, "nf-apex-adm"):
print("User is an Admin!")
# 4. Get full authorization tree (returns JSON string)
tree_json = helper.get_org_authorisations(raw_jwt)
print(json.loads(tree_json))
else:
print("❌ Invalid or Expired Token")
📦 Node.js Example
const { IdpAuthHelper } = require("@dhilipsiva/nf_ndc_connect_public");
const fs = require("fs");
// 1. Initialize
const publicKey = fs.readFileSync("./cert.pem", "utf8");
const helper = new IdpAuthHelper(publicKey);
const rawJwt = "eyJhbGciOiJ...";
// 2. Validate
const isValid = helper.isValid(rawJwt);
console.log(`Is Valid? ${isValid}`);
if (isValid) {
// 3. Check Role
const hasRole = helper.hasRole(rawJwt, "dhilipsiva_dev/nf-apex", "nf-apex-adm");
console.log(`Has Admin Role? ${hasRole}`);
// 4. Get Auth Tree
// Returns a native JS object (not a string) in Node
const tree = helper.getOrgAuthorisations(rawJwt);
console.log(tree);
}
🦀 Rust Example
use nf_ndc_connect_public::AuthHelper;
fn main() {
let public_key = include_str!("../cert.pem");
let helper = AuthHelper::new(public_key).expect("Invalid Key");
let jwt = "eyJhbGciOiJ...";
match helper.is_valid(jwt) {
Ok(claims) => {
println!("✅ Valid Token for subject: {}", claims.sub);
if helper.has_role(jwt, "dhilipsiva_dev/nf-apex", "nf-apex-adm") {
println!("User is Admin");
}
},
Err(e) => println!("❌ Error: {}", e),
}
}
🛠️ Development
This project uses Nix for a reproducible environment and Just for command automation.
Prerequisites
- Install Nix.
- Enable flakes (standard in newer installers).
Setup
Enter the development shell. This installs Rust, Python, Maturin, Node.js, and Wasm-Pack automatically.
nix develop
Build Commands (via just)
| Command | Description |
|---|---|
just py-dev |
Build Python wheel in debug mode & install to venv |
just py-build |
Build Python wheel for release |
just wasm |
Build the Wasm package for Node.js |
just test |
Run standard Cargo tests |
just clean |
Remove all build artifacts (target/, pkg/, .venv/) |
🚢 Release Process
To publish a new version to PyPI, NPM, and Crates.io simultaneously:
- Ensure you are in the Nix shell (
nix develop). - Run the release command:
# Usage: just release <version>
just release 0.2.3
This will:
- Update
Cargo.tomlandpyproject.toml. - Run checks.
- Commit the changes.
- Create a git tag
v0.2.3.
- Push to trigger CI/CD:
git push && git push --tags
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nf_ndc_connect_public-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: nf_ndc_connect_public-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 523.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44f8422b616bf1907c49bbff88315eaad9d71541edcd54b63b2a73a7d9001a8f
|
|
| MD5 |
049f8638818f3c5222a4f3f0b6648d48
|
|
| BLAKE2b-256 |
3b80c54adbe52ef6bcf81949c1896022deb22b2721a120a2ec42e357f5cfd53b
|
Provenance
The following attestation bundles were made for nf_ndc_connect_public-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on NuFlights/nf_ndc_connect_public
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nf_ndc_connect_public-0.4.1-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
44f8422b616bf1907c49bbff88315eaad9d71541edcd54b63b2a73a7d9001a8f - Sigstore transparency entry: 923392470
- Sigstore integration time:
-
Permalink:
NuFlights/nf_ndc_connect_public@4e27309c57364886d8322b7d0112e3e12139c903 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/NuFlights
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4e27309c57364886d8322b7d0112e3e12139c903 -
Trigger Event:
push
-
Statement type: