web_extensions_sys/
identity.rs

1//! Authorization via OAuth2.
2
3use js_sys::Function;
4use wasm_bindgen::prelude::*;
5
6#[wasm_bindgen]
7extern "C" {
8
9    pub type Identity;
10
11    #[wasm_bindgen(method, js_name = getRedirectURL)]
12    pub fn get_redirect_url(this: &Identity) -> String;
13
14    #[wasm_bindgen(method, js_name = getRedirectURL)]
15    pub fn get_redirect_url_with_path(this: &Identity, path: &str) -> String;
16
17    #[wasm_bindgen(method, catch, js_name = launchWebAuthFlow)]
18    pub async fn launch_webauth_flow(
19        this: &Identity,
20        details: &JsValue,
21    ) -> Result<JsValue, JsValue>;
22
23    #[wasm_bindgen(method, catch, js_name = launchWebAuthFlow)]
24    pub fn launch_webauth_flow_with_callback(
25        this: &Identity,
26        details: &JsValue,
27        callback: &Function,
28    ) -> Result<(), JsValue>;
29
30    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
31    pub fn get_auth_token(this: &Identity) -> Result<(), JsValue>;
32
33    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
34    pub fn get_auth_token_with_details(this: &Identity, details: &JsValue) -> Result<(), JsValue>;
35
36    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
37    pub fn get_auth_token_with_details_and_callback(
38        this: &Identity,
39        details: &JsValue,
40        callback: &Function,
41    ) -> Result<(), JsValue>;
42
43    // https://developer.chrome.com/docs/extensions/reference/identity/#method-getProfileUserInfo
44    #[wasm_bindgen(method, catch, js_name = getProfileUserInfo)]
45    pub async fn get_profile_user_info(
46        this: &Identity,
47        details: &JsValue,
48    ) -> Result<JsValue, JsValue>;
49}