1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Authorization via OAuth2.

use js_sys::Function;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {

    pub type Identity;

    #[wasm_bindgen(method, js_name = getRedirectURL)]
    pub fn get_redirect_url(this: &Identity) -> String;

    #[wasm_bindgen(method, js_name = getRedirectURL)]
    pub fn get_redirect_url_with_path(this: &Identity, path: &str) -> String;

    #[wasm_bindgen(method, catch, js_name = launchWebAuthFlow)]
    pub async fn launch_webauth_flow(
        this: &Identity,
        details: &JsValue,
    ) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
    pub fn get_auth_token(this: &Identity) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
    pub fn get_auth_token_with_details(this: &Identity, details: &JsValue) -> Result<(), JsValue>;

    #[wasm_bindgen(method, catch, js_name = getAuthToken)]
    pub fn get_auth_token_with_details_and_callback(
        this: &Identity,
        details: &JsValue,
        callback: &Function,
    ) -> Result<(), JsValue>;
}