| Crates.io | my-canister-dashboard |
| lib.rs | my-canister-dashboard |
| version | 0.11.0 |
| created_at | 2025-06-23 15:28:58.136367+00 |
| updated_at | 2026-01-11 19:42:40.825214+00 |
| description | Dashboard assets and management utilities for Internet Computer Canister Dapps |
| homepage | |
| repository | https://github.com/Web3NL/my-canister-dapp/tree/main/my-canister-dapp-rs/my-canister-dashboard |
| max_upload_size | |
| id | 1723055 |
| size | 387,949 |
Dashboard assets and management utilities for Internet Computer Canister Dapps.
Integrates with AssetRouter for asset certification.
/canister-dashboard/.well-known/ii-alternative-origins for II domain delegationuse ic_asset_certification::AssetRouter;
use my_canister_dashboard::setup;
use std::cell::RefCell;
use ic_cdk::{api::certified_data_set, init};
thread_local! {
static ASSET_ROUTER: RefCell<AssetRouter<'static>> = RefCell::new(
AssetRouter::new()
);
}
#[init]
fn init() {
ASSET_ROUTER.with(|router| {
let mut router = router.borrow_mut();
setup::setup_dashboard_assets(
&mut router,
Some(vec!["https://mycanister.app".to_string()]),
).expect("Failed to setup dashboard");
certified_data_set(router.root_hash());
});
}
Expose these in your canister to enable dashboard functionality:
use my_canister_dashboard::{
ManageIIPrincipalArg, ManageIIPrincipalResult,
guards::only_canister_controllers_guard,
};
use ic_cdk::update;
#[update(guard = "only_canister_controllers_guard")]
fn manage_ii_principal(arg: ManageIIPrincipalArg) -> ManageIIPrincipalResult {
my_canister_dashboard::manage_ii_principal(arg)
}
use my_canister_dashboard::{
ManageAlternativeOriginsArg, ManageAlternativeOriginsResult,
guards::only_canister_controllers_guard,
};
use ic_cdk::update;
#[update(guard = "only_canister_controllers_guard")]
fn manage_alternative_origins(arg: ManageAlternativeOriginsArg) -> ManageAlternativeOriginsResult {
ASSET_ROUTER.with(|router| {
my_canister_dashboard::manage_alternative_origins(&mut router.borrow_mut(), arg)
})
}
use my_canister_dashboard::{
ManageTopUpRuleArg, ManageTopUpRuleResult,
guards::only_ii_principal_guard,
};
use ic_cdk::update;
#[update(guard = "only_ii_principal_guard")]
fn manage_top_up_rule(arg: ManageTopUpRuleArg) -> ManageTopUpRuleResult {
my_canister_dashboard::manage_top_up_rule(arg)
}
Two guard functions for protecting endpoints:
only_canister_controllers_guard() - Allows only canister controllersonly_ii_principal_guard() - Allows only the configured II principaluse my_canister_dashboard::guards::{only_canister_controllers_guard, only_ii_principal_guard};
use ic_cdk::update;
#[update(guard = "only_canister_controllers_guard")]
fn admin_only_function() { /* ... */ }
#[update(guard = "only_ii_principal_guard")]
fn user_only_function() { /* ... */ }
The dashboard assets are served at these paths:
| Constant | Path |
|---|---|
CANISTER_DASHBOARD_HTML_PATH |
/canister-dashboard |
CANISTER_DASHBOARD_JS_PATH |
/canister-dashboard/index.js |
CANISTER_DASHBOARD_CSS_PATH |
/canister-dashboard/style.css |
ALTERNATIVE_ORIGINS_PATH |
/.well-known/ii-alternative-origins |
For local development, use @web3nl/vite-plugin-canister-dapp to configure the development environment.
MIT