Make all requests POST requests to match server and browser handling
This commit is contained in:
parent
5aaba881c8
commit
6ddd3baa46
|
@ -179,7 +179,7 @@ function requested_cred(command, requested) {
|
||||||
|
|
||||||
function request_open_invite() {
|
function request_open_invite() {
|
||||||
return new Promise((fulfill, reject) => {
|
return new Promise((fulfill, reject) => {
|
||||||
loxServerGetRequest("/invite").then((response) => {
|
loxServerPostRequest("/invite", null).then((response) => {
|
||||||
console.log("Got invitation token: " + response.invite);
|
console.log("Got invitation token: " + response.invite);
|
||||||
fulfill(response.invite);
|
fulfill(response.invite);
|
||||||
return;
|
return;
|
||||||
|
@ -192,7 +192,7 @@ function request_open_invite() {
|
||||||
|
|
||||||
function simple_request(requested) {
|
function simple_request(requested) {
|
||||||
return new Promise((fulfill, reject) => {
|
return new Promise((fulfill, reject) => {
|
||||||
loxServerGetRequest(requested).then((response) => {
|
loxServerPostRequest(requested, null).then((response) => {
|
||||||
fulfill(JSON.stringify(response));
|
fulfill(JSON.stringify(response));
|
||||||
return;
|
return;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
@ -202,34 +202,6 @@ function simple_request(requested) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loxServerGetRequest(data) {
|
|
||||||
return new Promise((fulfill, reject) => {
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
xhr.onreadystatechange = function() {
|
|
||||||
if (xhr.DONE !== xhr.readyState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (xhr.status !== 200) {
|
|
||||||
console.log("Error. Status code: "+xhr.status);
|
|
||||||
console.log(xhr);
|
|
||||||
reject();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const response = JSON.parse(xhr.responseText);
|
|
||||||
fulfill(response);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
xhr.open('GET', "http://localhost:8001"+data);
|
|
||||||
} catch (err) {
|
|
||||||
console.log("Error connecting to lox bridge db");
|
|
||||||
reject();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
xhr.send();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function loxServerPostRequest(data, payload) {
|
function loxServerPostRequest(data, payload) {
|
||||||
return new Promise((fulfill, reject) => {
|
return new Promise((fulfill, reject) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use chrono::{Duration, Utc, NaiveDate};
|
use chrono::{Duration, Utc};
|
||||||
use std::sync::atomic::{AtomicI64, Ordering};
|
|
||||||
use julianday::JulianDay;
|
use julianday::JulianDay;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use lox::bridge_table::{BridgeLine,from_scalar,BridgeTable, ENC_BUCKET_BYTES};
|
use lox::bridge_table::{BridgeLine,from_scalar,BridgeTable, ENC_BUCKET_BYTES};
|
||||||
use lox::cred::{BucketReachability, Invitation, Lox, Migration};
|
use lox::cred::{BucketReachability, Invitation, Lox, Migration};
|
||||||
use lox::proto::{open_invite, trust_promotion, migration, level_up,
|
use lox::proto::{open_invite, trust_promotion, migration, level_up,
|
||||||
|
@ -9,8 +7,6 @@ use lox::proto::{open_invite, trust_promotion, migration, level_up,
|
||||||
use lox::{IssuerPubKey, OPENINV_LENGTH, scalar_u32};
|
use lox::{IssuerPubKey, OPENINV_LENGTH, scalar_u32};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::{serde_as};
|
use serde_with::{serde_as};
|
||||||
use serde_json;
|
|
||||||
//use serde_wasm_bindgen;
|
|
||||||
use std::array::TryFromSliceError;
|
use std::array::TryFromSliceError;
|
||||||
use std::{panic};
|
use std::{panic};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
@ -141,8 +137,8 @@ pub fn open_invite(invite: &[u8]) -> Result<String, JsValue> {
|
||||||
};
|
};
|
||||||
let (request, state) = open_invite::request(&token);
|
let (request, state) = open_invite::request(&token);
|
||||||
let req_state = OpenReqState {
|
let req_state = OpenReqState {
|
||||||
request: request,
|
request,
|
||||||
state: state,
|
state,
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
log(&format!(
|
log(&format!(
|
||||||
|
@ -310,7 +306,7 @@ fn generate_reachability_cred(lox_cred: &Lox, encrypted_table: String) -> Bucket
|
||||||
let (id, key) = from_scalar(lox_cred.bucket).unwrap();
|
let (id, key) = from_scalar(lox_cred.bucket).unwrap();
|
||||||
let enc_buckets: EncBridgeTable = serde_json::from_str(&encrypted_table).unwrap();
|
let enc_buckets: EncBridgeTable = serde_json::from_str(&encrypted_table).unwrap();
|
||||||
let bucket = BridgeTable::decrypt_bucket(id, &key, &enc_buckets.etable[id as usize]).unwrap();
|
let bucket = BridgeTable::decrypt_bucket(id, &key, &enc_buckets.etable[id as usize]).unwrap();
|
||||||
return bucket.1.unwrap()
|
bucket.1.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
|
|
Loading…
Reference in New Issue