p47h_engine/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025 P47H Team <https://p47h.com>
3
4//! # p47h-engine
5//!
6//! Core engine for P47H with cryptographic identity management
7//! and local policy evaluation.
8//!
9//! This crate provides a complete AuthN/AuthZ solution for web applications.
10//! It is designed to be used as a library (rlib) by WASM wrappers.
11
12#![forbid(unsafe_code)]
13#![warn(missing_docs)]
14
15mod client;
16mod types;
17mod utils;
18mod validation;
19
20mod vault;
21mod wrappers;
22
23#[allow(unused_imports)]
24use wasm_bindgen::prelude::*;
25
26// Re-export main types
27pub use client::P47hClient;
28pub use types::{AuthDecision, AuthDecisionWithProof, PolicyDiagnostic};
29pub use utils::parse_resource;
30pub use validation::{validate_policy, validate_policy_detailed};
31pub use vault::VaultCrypto;
32pub use wrappers::{WasmIdentity, WasmPolicy};
33
34// Set panic hook for better error messages in browser console
35#[cfg(feature = "console_error_panic_hook")]
36pub use console_error_panic_hook::set_once as set_panic_hook;
37
38/// Initialize the engine (sets panic hook for debugging).
39/// This should be called by the WASM wrapper, not directly.
40pub fn init_engine() {
41    #[cfg(feature = "console_error_panic_hook")]
42    set_panic_hook();
43}