extern crate wasm_bindgen; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct WasmAccessControl { inner: crate::AccessControl, } #[wasm_bindgen] impl WasmAccessControl { #[wasm_bindgen(constructor)] pub fn new() -> Self { Self { inner: crate::AccessControl::new() } } pub fn check_access(&self, resource_name: &str, role_name: &str) -> bool { let resource = crate::Resource::new(resource_name, vec![role_name.to_string()]); self.inner.has_access(&resource) } pub fn generate_token(&self) -> String { crate::AccessControl::generate_secure_token() } } #[wasm_bindgen] pub fn init_panic_hook() { console_error_panic_hook::set_once(); }