/* * Copyright (c) 2022-2025 Niko Bonnieure, Par le Peuple, NextGraph.org developers * All rights reserved. * Licensed under the Apache License, Version 2.0 * * or the MIT license , * at your option. All files in the project carrying such * notice may not be copied, modified, or distributed except * according to those terms. */ #![cfg(target_arch = "wasm32")] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use ng_wallet::permissions::{AppManifest, *}; use sys_locale::get_locales; #[wasm_bindgen] pub fn encode_manifest_v0(origin: String, singleton: bool, access_requests: JsValue) -> Result { let access_requests = serde_wasm_bindgen::from_value::>(access_requests).map_err(|_| "Invalid access_requests list")?; let url_param = if access_requests.len() == 0 { AppManifest::new_for_origin_all_access_v0(origin) } else { AppManifest::new_v0(origin, singleton, access_requests) }.to_url_param(); Ok(serde_wasm_bindgen::to_value(&url_param).unwrap()) } #[wasm_bindgen] pub fn locales() -> Result { Ok(serde_wasm_bindgen::to_value(&get_locales().collect::>()).unwrap()) }